Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run update query using VBA

Status
Not open for further replies.

ProgramError

Programmer
Mar 2, 2005
1,027
GB
I have the follow SQL statement taken from a query created using the query design view in Access.

UPDATE mytable SET mytable.Printed = Yes
WHERE ((mytable.Marked) = True)


Unfortunantly the help in access is a little sparce. My intention is to alter the 'where' part of the string to lookup and update selected records (this part I can do), but I need to run this query using VBA. do I need to create a querydef? do I need to create a recordset. How do I run this sql statement in VBA [sadeyes]

Totally Clueless!

Program Error
Why is it, I still think in terms of spectrum BASIC!
 
Is is something like this you're after?

[tt]currentdb.execute "UPDATE mytable SET mytable.Printed = True " & _
"WHERE ((mytable.Marked) = True)",dbfailonerror[/tt]

Roy-Vidar
 
DoCmd.RunSQL "UPDATE mytable SET mytable.Printed=Yes WHERE mytable.Marked=True"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks...

why does MS help make everything so confusing!

will try both methods and the additional one I just happen to receive in a crosspost. Well... I didn't know if it was a query or VBA question. Sorry if it upset anyone. Won't do it again![thumbsup2]



Program Error
Why is it, I still think in terms of spectrum BASIC!
 
guess what! they all work!


Program Error
Why is it, I still think in terms of spectrum BASIC!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top