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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Run-time error '13'. Type mismatch.

Author  Topic 

Lin100
Yak Posting Veteran

70 Posts

Posted - 2006-09-10 : 12:04:01
Access 2003 and SQL 2000 Server

Run-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.



Go to Top of Page

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
Go to Top of Page

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)?


Go to Top of Page

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 it
add a new record onto this form. The new record are consisted of 4 values from 4 combo box mentioned earlier.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-10 : 20:48:34
Try

Set Recordset_Meter_Query = Recordset_Meter.Recordset

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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......
Go to Top of Page

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.

Go to Top of Page
   

- Advertisement -