laurenh5516
New Member
- Joined
- Nov 20, 2017
- Messages
- 9
I am trying to code parameters in excel VBA from an access query that has 2 date parameters. I have parameters in my code, but I still get an error code that says 2 parameters are expected.
Sub UpdateForecast()
Application.ScreenUpdating = False
'On Error Resume Next
Dim MyDatabase As DAO.Database
Dim QueryDef As DAO.QueryDef
Dim i As Integer
Set MyDatabase = DBEngine.OpenDatabase _
("C:\Users" & Environ("UserName") & "\Turnaround Tracking\Construction Hiring Plan.accdb")
Set QueryDef = MyDatabase.QueryDefs("qry_WeekendForecastOfficial")
Set MyQuery = QueryDef.OpenRecordset
QueryDef.Parameters(0) = InputBox("Select Start Date")
QueryDef.Parameters(0) = InputBox("Select Finish Date")
Sub UpdateForecast()
Application.ScreenUpdating = False
'On Error Resume Next
Dim MyDatabase As DAO.Database
Dim QueryDef As DAO.QueryDef
Dim i As Integer
Set MyDatabase = DBEngine.OpenDatabase _
("C:\Users" & Environ("UserName") & "\Turnaround Tracking\Construction Hiring Plan.accdb")
Set QueryDef = MyDatabase.QueryDefs("qry_WeekendForecastOfficial")
Set MyQuery = QueryDef.OpenRecordset
QueryDef.Parameters(0) = InputBox("Select Start Date")
QueryDef.Parameters(0) = InputBox("Select Finish Date")
Last edited: