I am trying to establish a recordset in which I can pull information from a query to populate text boxes on a form. I want the query results to be based on two fields on the form (item & warehouse).
My original code was giving me the “too few parameters. expected 2” error. I had the parameters in the query itself.
I found a post on this site with instructions and a link to http://support.microsoft.com/default...b;en-us;209203 in which suggested the code below. The error I’m getting with this code is “Item not found in collection.”
Can anyone tell me what I’m doing wrong?
Dim db As Database
Dim rsTable As Recordset
Dim qdfPara1 As QueryDef
Dim strSearchItem As String
Set db = CurrentDb
Set qdfPara1 = db.QueryDefs("QryGetItemInfo")
‘When I hover this line, I see the correct item number
strSearchItem = Forms![frmInvValItemMaint]![txtItem]
‘This is the error line in debug
qdfPara1![Forms!frmInvValItemMaint!txtItem] = strSearchItem
Set rsTable = qdfPara1.OpenRecordset()
Me.TxtDescription.Value = rsTable![Description]
p.s. I took out the extra line references to the warehouse to simplify things
My original code was giving me the “too few parameters. expected 2” error. I had the parameters in the query itself.
I found a post on this site with instructions and a link to http://support.microsoft.com/default...b;en-us;209203 in which suggested the code below. The error I’m getting with this code is “Item not found in collection.”
Can anyone tell me what I’m doing wrong?
Dim db As Database
Dim rsTable As Recordset
Dim qdfPara1 As QueryDef
Dim strSearchItem As String
Set db = CurrentDb
Set qdfPara1 = db.QueryDefs("QryGetItemInfo")
‘When I hover this line, I see the correct item number
strSearchItem = Forms![frmInvValItemMaint]![txtItem]
‘This is the error line in debug
qdfPara1![Forms!frmInvValItemMaint!txtItem] = strSearchItem
Set rsTable = qdfPara1.OpenRecordset()
Me.TxtDescription.Value = rsTable![Description]
p.s. I took out the extra line references to the warehouse to simplify things