Sql code not working (1 Viewer)

Jediphase

Registered User.
Local time
Today, 16:08
Joined
Apr 18, 2002
Messages
38
Can anyone tell me what needs to be added into this to work please?

Table wanting to update is worker, the field within worker is applicant. It finds it but the where claus of the sql isnt working.

I want to find the record where worker.name field = a field on a form called wdetails (the field is called name)

DoCmd.RunSQL "update worker " & _
"Set worker.applicant = true " & _
"WHERE worker.name= form_wdetails.name;"

the table behind the form wdetails is maindetails

If you need any more info please ask!

Thank you
 

Travis

Registered User.
Local time
Today, 08:08
Joined
Dec 17, 1999
Messages
1,332
Try this:

DoCmd.RunSQL "update worker " & _
"Set worker.applicant = true " & _
"WHERE worker.name='" & Forms![form_wdetails].[Name] & "'"


Also when you are having trouble with SQL statements in code, a good practice to get into is using the "Debug.Print" statement to send the SQL to the "Imediate Window". You can then copy and paste it to the SQL View of a new Query and attempt to run it from there. Errors will become more obvious.
 

Jediphase

Registered User.
Local time
Today, 16:08
Joined
Apr 18, 2002
Messages
38
Brilliant!

Cheers Travis it worked a treat!

It was just specifying a field in a form rather than table and i had done it before but just couldnt remember for love nor money!

Cheers pal!

J
 

Users who are viewing this thread

Top Bottom