Passing parameters to a query

‘SET THE PARAMETERS FOR THE SELECT QUERY CALLED Q-GIFTAID-PART1 WHICH NEEDS
‘ A STARTING VALUE (StartDate) and an ending value ((EndDate)
StartDate = InputBox(“Enter start Date”)
EndDate = InputBox(“Enter finish date”)

Set dbs = CurrentDb
Set qdf = dbs.QueryDefs(“Q-GiftAid-PART1”)
qdf.Parameters(“Enter Start Date”) = StartDate ‘”Enter Start Date” is the first parameter looked for in the Query
qdf.Parameters(“Enter Ending Date”) = EndDate ‘”Enter Ending Date” is the second parameter looked for
Set GiftAid = qdf.OpenRecordset

qdf.Close

Set qdf = Nothing

Comments are closed