"Run-time error '3464':"

  • Thread starter Thread starter claudeg007
  • Start date Start date
C

claudeg007

Guest
Hi all,

I need your help on the following issue :

I have a table 'T1' with an AutoNumber field 'T1Id', a text field 'TF' and a Yes/No field 'YNF'.

I have another table 'T2' with an AutoNumber field 'T2Id' and a Yes/No field 'YNF2'.

I have a form with a combolist 'Model' an option button having its source data linked to T2.YNF2

When I change the state of the Option button 'OptBtn1', the field 'YNF2' of 'T2' is well updated, no problem on this one.

Now, I also need to update the field 'YNF' of table 'T1', with the record number depending of the combobox selection. I'm doing this through code at the AfterUpdate call :

Private Sub OptBtn1_AfterUpdate()
DoCmd.RunSQL ("UPDATE T1 SET T1.YNF = False WHERE T1.T1Id='" & Model.Value & "'")
End Sub

At execution, I got the error "Run-time error '3464': - Data type mismatch in criteria expression".
Could someone point me where I'm wrong ?
 
claudeg007 said:
Hi all,

I have a form with a combolist 'Model' an option button having its source data linked to T2.YNF2

Private Sub OptBtn1_AfterUpdate()
DoCmd.RunSQL ("UPDATE T1 SET T1.YNF = False WHERE T1.T1Id='" & Model.Value & "'")
End Sub

You very clearly stated that you have an autonumber, boolean, and text field in each table, but then you said that you stored Model in the Boolean YNF2 and then you're trying to set the T1.YNF =False WHERE T1.T1ID = '" & Model.Value & "'

'" & Model.Value & "' is a string and you're trying to pass it back to an ID/Autonumber field

If Model.Value is actually a numeric value (foreign key or something) then you need to get rid of the '" & & "'

HOpe that helps!
 
you are passing T1Id as a text value, try
DoCmd.RunSQL ("UPDATE T1 SET T1.YNF = False WHERE T1.T1Id=" & Model.Value )

peter
 
You got it Bat17 !
My bad, I didn't see this one :confused:

Thanks very much to you guys.
 

Users who are viewing this thread

Back
Top Bottom