RUNSQL Question

  • Thread starter Thread starter sfleck
  • Start date Start date
S

sfleck

This simple statement is not working

Private Sub Command0_Click()
Dim strSQL As String
strSQL = "SELECT * FROM MailFairTable;"
DoCmd.RunSQL strSQL
End Sub

i have even tried this
DoCmd.RunSQL "SELECT * FROM MailFairTable;"

Even tried Execute

The Statement is simple but is erring out

Any Guidance is Appreciated
 
Sorry forgot the error

A RunSQL action requires an argument consisting of an SQL statement

RunTime error '2342'
 
sfleck said:
This simple statement is not working
DoCmd.RunSQL "SELECT * FROM MailFairTable;"

RunSQL requires an action query. That is updating, inserting or
deleting records. You're viewing records.

So what is it you're trying to do?

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Thank you for the response

I was trying to set up a form that would return the selected amount of
records.

I was looking ultimately for a way around not being able to parametrize the
quantity in a SELECT TOP Statement
 
sfleck said:
I was trying to set up a form that would return the selected amount of
records.

I was looking ultimately for a way around not being able to parametrize the
quantity in a SELECT TOP Statement

You will need to update the form RecordSource in the form Open event.
Alternatively if the user is entering the quantity on another form
which opens this form then the forms recordsource query could
reference the other forms field to get the quantity.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top