Update a field in a table from a form with vba /problem

Asghaar

Registered User.
Local time
Today, 17:19
Joined
Jul 4, 2012
Messages
47
Hello all,

I have the following problem .
I have a command button that inserts and e-mail adress in a table.
In the same clikc event i want to update the field in another table that corresponds to the e-mail clicked.
Unfortunately,don't know why ( probably because i don't know very well ), can't make the update part work.

Right now i have :

-everything is text,not numeric

Code:
Dim sql2 As String
Dim varwhereClause as String

varwhereClause = Me![Email]
sql2 = "Update T_all set T_all.DND = " * " where (([Email]= """ & varwhereClause  & """)); "
DoCmd.RunSQL sql2

Thank you very much for your help.
 
Try changing the varwhereclause to the entire criteria, bracket the stuff and separate the strings so you can see if they evaluate to what you expect. Do you know that you can stop the execution by clicking in the left margin so you can see the string?

varwhereclause = "([T_all].="" & me.email.value & "")"

sql2 = "Update [T_all] Set [T_all].[DND]=""*""

sql2 = sql2 & " WHERE (" & varwhereclause & ");"

Hope this helps, Privateer
 
Hello,

Thanks to privateer managed to found the right solution.
It looks like :

Code:
sql2 = "Update T_all Set Used=""*"""
sql2 = sql2 & " WHERE ( Email=""" & varwhereClause & """);"

Once again thank you Privateer for the good direction.


Regards,
 

Users who are viewing this thread

Back
Top Bottom