Update a field in a table from a form with vba /problem (1 Viewer)

Asghaar

Registered User.
Local time
Today, 08:35
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.
 

Privateer

Registered User.
Local time
Today, 01:35
Joined
Aug 16, 2011
Messages
193
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
 

Asghaar

Registered User.
Local time
Today, 08:35
Joined
Jul 4, 2012
Messages
47
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

Top Bottom