how do I change the value of a field

Jackske

Registered User.
Local time
Today, 12:12
Joined
Feb 28, 2000
Messages
48
I am French speaking, so sorry for the faults.
I made a new module
In this module I did a "Sub"
I this Sub I search for a value in a table "A"
Now, I want to change the value of a field inside an other table "B"
How can I do this without leaving my Sub ?

Thanks in advance,

Jackske/Belgium
 
here is the basic idea if you need more help, then just ask

Code:
DoCmd.SetWarnings False
strSQL = "UPDATE tblYourTabe SET tblYourTabe.FieldToUpdate = 'NewValue' WHERE tblYourTabe.ID=3;"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

Peter
 
Dear Peter,
Thank a lot for your fast reaction.
Here is the code I wrote following your instruction
--------------------------------------------------------
DoCmd.SetWarnings False
strSQL = "UPDATE tblLeden SET tblLeden.lidgeld_betaald = 'J' WHERE tblLeden.ID=3;"
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
--------------------------------------------------------
when I start this SUB I got a question box
Enter Parameter Value
tblLeden.ID

I forgot to mention that I want to change the value of a field in an other table with a criteria .... something like WHERE Lid_Id=...
 
"UPDATE tblLeden SET tblLeden.lidgeld_betaald = 'J' WHERE tblLeden.ID=3;"
This would update the field 'lidgeld_betaald' to 'J' Where ID = 3

do you have an field called ID in tblLeden?

You will probably want to build the SQL string using data from your other table, you would do it something like

"UPDATE tblLeden SET tblLeden.lidgeld_betaald = '" & strData & "' WHERE tblLeden.ID=" & intID & ";"

where the variables strData and strData would be filled from your first table.
Note that strData is wrapped in single quotes ' while there are no extra quotes around the ID, Strings need wrapping Numbers dont.

HTH

Peter
 
Dear Peter,

:) I am afraid that with such a name you have to be a man because I want to kiss you on your lips.
You resolved my problem. I would never have find this by myself.
Thanks a lot
Jackske/Belgium
 

Users who are viewing this thread

Back
Top Bottom