Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Lin100
Yak Posting Veteran
70 Posts |
Posted - 2006-09-10 : 12:04:01
|
Access 2003 and SQL 2000 ServerRun-time error '13'. Type mismatch. Yellow highlight is at the code below Set Recordset_Meter_Query = Me.Recordset''''''''''''''''''''''''''''''''''''''''''''''''''Private Sub Form_Load() Dim Str_SQL As String Dim Number_Of_Records As Integer Dim Recordset_Meter As New ADODB.Recordset Dim Recordset_Meter_Query As ADODB.Recordset Dim cmd As ADODB.Command Dim cnThisConnect As ADODB.Connection Set cnThisConnect = CurrentProject.Connection Set cmd = New ADODB.Command Set cmd.ActiveConnection = CurrentProject.Connection Str_SQL = "SELECT * FROM Meter;" Recordset_Meter.Open Str_SQL, cnThisConnect, _ adOpenKeyset, adLockOptimistic, adCmdText Set Recordset_Meter_Query = Me.Recordset <-- THE ERROR IS HERE Number_Of_Records = Recordset_Meter_Query.RecordCount If Number_Of_Records = 0 Then Recordset_Meter_Query.addnew Recordset_Meter_Query!Department_Name = Public_Department_Name Recordset_Meter_Query!SONumber = Public_SO_Number Recordset_Meter_Query!ItemNumber = Public_Item_Number Recordset_Meter_Query!Section_Number = Public_Section_Number Recordset_Meter_Query.Update Me.Requery End If End Sub |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-09-10 : 17:53:46
|
Try using Me.RecordsetClone.I haven't really used it much but I believe that's the way to get a copy of the rst. |
 |
|
Lin100
Yak Posting Veteran
70 Posts |
Posted - 2006-09-10 : 19:17:40
|
Hi timmy. I did as you have suggested, but it still gives me the same error message.Run-time error '13'. Type mismatch.Yellow highlight is at the code below Set Recordset_Meter_Query = Me.RecordsetClone |
 |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-09-10 : 19:36:49
|
Hmmm... as I say, I hadn't really used it before. More of a guess than anything else.What are you trying to do (from a high-level if possible)? |
 |
|
Lin100
Yak Posting Veteran
70 Posts |
Posted - 2006-09-10 : 20:07:09
|
Hi timmy.Originally the code is in DAO, and it worked. I now changed it to work for ADO because all of the table are in SQL 2000 Server.A user click a button (button_1). A form is opened. This form's recordsource is a query that reference 4 combo box on the same form as button_1 is located. If the query did find a record, then the record will appear on that form. If a query does not found that record, then itadd a new record onto this form. The new record are consisted of 4 values from 4 combo box mentioned earlier. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-10 : 20:48:34
|
TrySet Recordset_Meter_Query = Recordset_Meter.RecordsetMadhivananFailing to plan is Planning to fail |
 |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-09-10 : 21:42:03
|
You can use DAO on SQL Server 2000.Might save you a bit of work...... |
 |
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-09-10 : 21:48:38
|
Just realised that you might be using an ADP..... so DAO isn't really an option.I would forget about using the recordset to add the records and create a stored proc. From my experience with Access it's best to keep it simple. So you can:- execute a stored proc to insert the record- requery the underlying dataset and update your form- if necessary the recordset Find functions to re-position to the new record. |
 |
|
|
|
|