Update specific record in table

TomBP

Registered User.
Local time
Today, 03:30
Joined
Jul 6, 2006
Messages
49
Hi,

I have written a function which sets the checkbox for all records in tbl_Questions to true.

Code:
Function frm_1_Passage_Q1_Ja()

Dim strSQL As String
 
strSQL = "UPDATE tbl_Questions " _
& "SET tbl_Questions.Answer = True" _
CurrentDb.Execute strSQL, dbFailOnError

End Function

I however only want the checkbox to be set to true for a specific record. Therefore a "where statement" was added to the earlier mentioned function. Unfortunately this leads to a run-time error.

Code:
Function frm_1_Passage_Q1_Ja()

Dim strSQL As String
 
strSQL = "UPDATE tbl_Questions " _
& "SET tbl_Questions.Answer = True" _
& "Where tbl_Questions.ID = 1"
CurrentDb.Execute strSQL, dbFailOnError

End Function

Can anyone tell me what the problem might be?

See attachment for print screens
 

Attachments

  • Print screens.jpg
    Print screens.jpg
    99.7 KB · Views: 158
Put a space before the "W" in Where

It is a good practice to do a Debug.print of your sql before attempting to run/execute it.
Updates can be quite unforgiving. So, do the print to ensure the syntax is good before executing.
 
Thx jdraw. That did the trick.
 

Users who are viewing this thread

Back
Top Bottom