UPDATE statement

dannyy1993

Registered User.
Local time
Today, 15:04
Joined
Jan 12, 2014
Messages
24
I have tried to update a record by using the UPDATE statement but it won't work.
This is my code:
CurrentDb.Execute "UPDATE dbo_Reservering.Betaald" & _
"SET Betaald = 'me.lijstKeuzeBetaaldVeranderen.Value' " & _
"WHERE Reserveringnummer = txtReserveringnummerAuto"


betaald is a bit but in the comobox you can choose Yes Or No
and reserveringnummer is just a number
 
but it won't work.

Tell us more. This doesn't help.
Error messages?

Try this syntax

CurrentDb.Execute "UPDATE dbo_Reservering.Betaald" & _
"SET Betaald = '" & me.lijstKeuzeBetaaldVeranderen.Value & _
"' WHERE Reserveringnummer = txtReserveringnummerAuto", dbFailOnError
 
If that is your code exactly, you are missing a space before SET.
 
CurrentDb.Execute "UPDATE dbo_Reservering.Betaald" & _
"SET Betaald = '" & me.lijstKeuzeBetaaldVeranderen.Value & _
"' WHERE Reserveringnummer = txtReserveringnummerAuto", dbFailOnError





I have to change "Betaald" from Nee to Ja, but in the database "Betaald" is a bit.
me.lijstKeuzeBetaaldVeranderen is a combobox with Ja and Nee
 
Code:
CurrentDb.Execute "UPDATE dbo_Reservering.Betaald " & _
"SET Betaald = '" & me.lijstKeuzeBetaaldVeranderen.Value & _
"' WHERE Reserveringnummer = txtReserveringnummerAuto", dbFailOnError

Inserted your missing space for you.
 
I have now the code:
CurrentDb.Execute "UPDATE dbo_Reservering.Betaald " & _
"SET Betaald = '" & Me.lijstKeuzeBetaaldVeranderen.Value & _
"' WHERE Reserveringnummer = txtReserveringnummerAuto ", dbFailOnError



But now I get the Error 3024 --> cannot find the file C:\Users\Danny\Documents\dbo_Reservering.mdb
 
Since your problem was resolved, please update the thread subject with "[SOLVED]".
 
I'm afraid my problem is not solved I wish it was, because it's a school project
 
Looks like your Backend file is not linked properly. Maybe the location has been changed or the file has been renamed. Relink the tables to the DB and try again.
 
Code:
CurrentDb.Execute " UPDATE dbo_Reservering.Betaald " & _
                  " SET Betaald = '" & Me.lijstKeuzeBetaaldVeranderen.Value & "'" & _
                  " WHERE Reserveringnummer = " & txtReserveringnummerAuto, dbFailOnError
Please take note of the small (additional) change I made to your SQL, which was probably sadly overlooked

Also take note of the changed format, readable code is maintainable code :banghead:

But now I get the Error 3024 --> cannot find the file C:\Users\Danny\Documents\dbo_Reservering.mdb
What Paul said.

Edit: regards from Amsterdam
 

Users who are viewing this thread

Back
Top Bottom