Running A query from VBA

  • Thread starter Thread starter chris
  • Start date Start date
C

chris

I have created a form for a user to select values from
multiple combo boxes. From that I want to run a query
based on the select criteria after pressing a command
button. I have built the SQL query (i think) and want to
create and display the query. How do I do this? this is
what i have. what comes next? Thanks

Private Sub Command7_Click()

dateend = Me.cbodateend.Value
datestart = Me.cboDatestart.Value
media = Me.cboMediabox.Value

If IsNull(media) = True Then
MsgBox ("Please specify the meida")
End If
If IsNull(datestart) = True Then
MsgBox ("Please specify the starting date")
End If
If IsNull(dateend) = True Then
MsgBox ("Please specify the ending date")
End If

Dim strSQL As String
strSQL = "SELECT FROM (tbldata INNER .....

End Sub
 
You have stepped over that grey line to VBA programming, so you just log a
few hours in one of the Coding Newsgroups, as well as a nice beginning VBA
book. Pick one, any one, for now, just to get you started.

But, once your SQL string is complete, you will need to execute it, like:

rst.Open strSQL
currentdb.execute strSQL


--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
Back
Top