blueboy2001
04-06-2004, 03:27 AM
I am bulding a form, and I would like to populate a data grid on it with the results of a query, which is simple enough. However, I want to pass parameters to the query, these parameters being the value of a combobox on the form at the date selected on the form.
I have come up with the following code
Private Sub cmdcheck_Click()
Dim strsql As String
Dim jdate As Date
Dim eid As Integer
txtdate.SetFocus
jdate = txtdate
cboEquipment.SetFocus
eid = cboEquipment.Value
strsql = "SELECT EQUIPMENTID, DESCRIPTION, DATE, job.JOBID FROM EQUIPMENT, JOBEQUIPMENT, JOB WHERE " & _
"DATE = CDATE(jdate) AND EquipmentID = (eid)"
CurrentDb.QueryDefs("qryTest").SQL = strsql
DoCmd.OpenQuery "qrytest", acViewNormal
Problem is this isn't passing the parameters, but opening an inputbox for me to type them in.
Where am I going wrong? Thanks for any advice.
I have come up with the following code
Private Sub cmdcheck_Click()
Dim strsql As String
Dim jdate As Date
Dim eid As Integer
txtdate.SetFocus
jdate = txtdate
cboEquipment.SetFocus
eid = cboEquipment.Value
strsql = "SELECT EQUIPMENTID, DESCRIPTION, DATE, job.JOBID FROM EQUIPMENT, JOBEQUIPMENT, JOB WHERE " & _
"DATE = CDATE(jdate) AND EquipmentID = (eid)"
CurrentDb.QueryDefs("qryTest").SQL = strsql
DoCmd.OpenQuery "qrytest", acViewNormal
Problem is this isn't passing the parameters, but opening an inputbox for me to type them in.
Where am I going wrong? Thanks for any advice.