Group:  Microsoft Excel ยป microsoft.public.excel.querydao
Thread: How to run Update query on Access table from Excel VBA

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How to run Update query on Access table from Excel VBA
Philip Brown 10.12.2005 21:28:02
Hello,

I want to run the following update query in Excel:

UPDATE WTMData SET WTMData.HALOT = "myvariable", WTMData.BDB = "myvariable",
WTMData.AlternateGloss = "myvariable", WTMData.GlosserInitials = "apb",
WTMData.GlossDate = Date() & " " & Time(), WTMData.Parsing = "myvariable"
WHERE (((WTMData.HALOT) Is Null) AND ((WTMData.BDB) Is Null) AND
((WTMData.AlternateGloss) Is Null) AND ((WTMData.GlosserInitials) Is Null)
AND ((WTMData.GlossDate) Is Null) AND ((WTMData.Parsing)="myvariable") AND
((WTMData.Lemma)="myvariable") AND ((WTMData.WTMOccurrences)<100) AND
((WTMData.WTMParsing) Not Like "myvariable" And (WTMData.WTMParsing) Like
"myvariable") AND ((WTMData.[H/A])="myvariable"));

How would I run it from within Excel?
Thanks!
RE: How to run Update query on Access table from Excel VBA
Philip Brown 11.12.2005 02:39:02
Figured out how to do this by looking at other comments in this newsgroup.
Posting the answer for anyone else who would like to know:

sqlString = _
"UPDATE WTMData SET WTMData.HALOT = " & sHALOTDef & ", " & _
"WTMData.BDB = " & sBDBDef & ", WTMData.AlternateGloss = " & sAltDef & ", "
& _
"WTMData.GlosserInitials = ""apb"", WTMData.GlossDate = Date() & "" "" &
Time() " & _
"WHERE (((WTMData.HALOT) Is Null) AND ((WTMData.BDB) Is Null) AND " & _
"((WTMData.AlternateGloss) Is Null) AND ((WTMData.GlosserInitials) Is Null)
AND " & _
"((WTMData.GlossDate) Is Null) AND ((WTMData.Parsing) Is Null) AND " & _
"((WTMData.Lemma)=" & sLemma & ") AND ((WTMData.WTMOccurrences)<100) AND " & _
"((WTMData.WTMParsing) Not Like ""np*"") AND ((WTMData.[H/A])=""H""));"

Set dbs = OpenDatabase("C:\mydatabase.mdb")
With dbs
.Execute sqlString, dbFailOnError
.Close
End With
Set dbs = Nothing

Merry Christmas!
Philip Brown

"Philip Brown" wrote:

[Quoted Text]
> Hello,
>
> I want to run the following update query in Excel:
>
> UPDATE WTMData SET WTMData.HALOT = "myvariable", WTMData.BDB = "myvariable",
> WTMData.AlternateGloss = "myvariable", WTMData.GlosserInitials = "apb",
> WTMData.GlossDate = Date() & " " & Time(), WTMData.Parsing = "myvariable"
> WHERE (((WTMData.HALOT) Is Null) AND ((WTMData.BDB) Is Null) AND
> ((WTMData.AlternateGloss) Is Null) AND ((WTMData.GlosserInitials) Is Null)
> AND ((WTMData.GlossDate) Is Null) AND ((WTMData.Parsing)="myvariable") AND
> ((WTMData.Lemma)="myvariable") AND ((WTMData.WTMOccurrences)<100) AND
> ((WTMData.WTMParsing) Not Like "myvariable" And (WTMData.WTMParsing) Like
> "myvariable") AND ((WTMData.[H/A])="myvariable"));
>
> How would I run it from within Excel?
> Thanks!

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net