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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.RunSQL mystery 1

Status
Not open for further replies.

vedicman

Programmer
Sep 5, 2003
128
US
When I run the following sub, a message pops up saying,

"A runSQL action requires an argument consisting of a SQL statement"

Sub test()

Dim sSQL As String

sSQL = "SELECT PRCR_ID FROM [Access PCPs Counts Only]"

DoCmd.RunSQL sSQL

End Sub

Can anyone tell me what, if anything, I'm doing wrong?

Thanks...Franco
 
You cannout have a Select query with RunSQL, only an Action query.
 
Remou

Thank for the clarification.

Perhaps you can tell me how to do this another way. What I want to do is run a SQL statement that gets a count of Doctors and assigns the value to an integer variable.

Any suggestions...with sample please.

Thanks....Franco
 
You could open a recordset on the data and use its .RecordCount property...

Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
 
... Or you could use DCount:

[tt]intInt = DCount("*","Table Or Query Name","FieldX=1")
intInt = DCount("*","Table Or Query Name")[/tt]
 
Remou

Thanks alot! I don't get into Access very often, and it's a challenge when I do.

this line did the trick:
intInt = DCount("*","Table Or Query Name","FieldX=1")

Thanks....Franco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top