Sabtu, 03 Mei 2014

[MS_AccessPros] Need help setting up query in VBA

 

I'm trying to set up an update query to run in VBA but am having problems getting the syntax right. Here's the SQL from the QBE grid:

UPDATE Votes SET Votes.PartyVoted = "O" WHERE (((Votes.PartyVoted)="G" Or (Votes.PartyVoted)="NP" Or (Votes.PartyVoted)="S" Or (Votes.PartyVoted) Is Null Or (Votes.PartyVoted)="L"));

This query runs find when I manually execute it, but I want to be able to execute is as a part of a data import routine so I don't forget to run it. Here's what I have now, but it doesn't work presumedly because I don't have the O, G, NP, etc., properly "escaped" for VBA. But I'm sure there could be other issues as well.
-----
SQL_text = "UPDATE Votes SET Votes.PartyVoted = ""O""" & _
        "WHERE (((Votes.PartyVoted)=""G""" & _
        "Or (Votes.PartyVoted)=""NP""" & _
        "Or (Votes.PartyVoted)=""S""" & _
        "Or (Votes.PartyVoted) Is Null Or (Votes.PartyVoted)=""L""" & "));"
        
DoCmd.RunSQL SQL_text
——

How do I need to change this to the the query to execute properly?  Using Access 2010.

Thanks for the help!

——
James
www.james-mc.com
Words To Live By

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Did you check out automatic photo albums in Yahoo Groups?
When you send mail to your Yahoo Group with photos attached, a photo album with attached photos is automatically created. When your group members reply to the email with photo attachments, those photos are added to the 'photomatic' albums automatically!

.

__,_._,___

Tidak ada komentar:

Posting Komentar