Access VBA newbie here and need a little help getting this to work. I have a select query set up with two parameters on one field so I can use a date range:
Between [Start Date] And [End Date]
This works just fine when running the query all by itself.
I have created a form which allows the user to enter the Start Date and End Date and then runs the query when selecting a button. The problem I'm having is no results show up. The code runs through but doesn't display even an empty results page.
My code is below. The message box fires at the end but nothing displays on the screen prior to that. I've tried using ("Start Date") and ("End Date") in place of (0) and (1) for the parameters and that doesn't work either.
I've also checked the me.StartDateTB and me.EndDateTB values and they are correct.
Any help you could give me would be appreciated.
Expand|Select|Wrap|Line Numbers
- Private Sub RunBtn_Click()
- Dim db As DAO.Database
- Dim qdf As DAO.QueryDef
- Dim rst As DAO.Recordset
- Set db = CurrentDb
- Set qdf = db.QueryDefs("TestStep1")
- qdf.Parameters(0) = Me.StartDateTB
- qdf.Parameters(1) = Me.EndDateTB
- Set rst = qdf.OpenRecordset
- MsgBox "finished"
- End Sub