Hi
I've attached a little code...
"qryDespatch" has a parameter "p1".
When I run this code I get an error which is a data type conversion error - runtime error 3421 so the parameter is expected as a different type. However the query is fine when I run it based on the form so I'm obviously not passing the parameter correctly.
Anyone have any ideas where I'm going wrong?
The error comes up on the "set fred" line.
Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database
Set dbs = CurrentDb
p1 = Forms("frmDespatchChoice").cmbOrderNoFilter.Value
Set fred = dbs.OpenRecordset("qryDespatch", "PARAMETERS ORDER_NUMBER" & p1)
DoCmd.GoToRecord acDataQuery, "qryDespatch", acFirst
Do
n = fred.QtyDespNoCarr + fred.qtyDelNoCarr
MsgBox n
DoCmd.GoToRecord acDataQuery, "qryDespatch", acNext
Loop
End Sub
Thanks
Andy
I've attached a little code...
"qryDespatch" has a parameter "p1".
When I run this code I get an error which is a data type conversion error - runtime error 3421 so the parameter is expected as a different type. However the query is fine when I run it based on the form so I'm obviously not passing the parameter correctly.
Anyone have any ideas where I'm going wrong?
The error comes up on the "set fred" line.
Private Sub Report_Open(Cancel As Integer)
Dim dbs As Database
Set dbs = CurrentDb
p1 = Forms("frmDespatchChoice").cmbOrderNoFilter.Value
Set fred = dbs.OpenRecordset("qryDespatch", "PARAMETERS ORDER_NUMBER" & p1)
DoCmd.GoToRecord acDataQuery, "qryDespatch", acFirst
Do
n = fred.QtyDespNoCarr + fred.qtyDelNoCarr
MsgBox n
DoCmd.GoToRecord acDataQuery, "qryDespatch", acNext
Loop
End Sub
Thanks
Andy