Can someone tell me what’s wrong with this code? I have a NotInList event that displays the Add New Record button and calls the below function. This function (PopulateItemTxtBoxes) is supposed to run a query to collect all the item information needed from a set of tables, populate/store that item info in text boxes on the form so that when the user clicks the add new record button, the item and all it’s info will be added to the table.
Private Function PopulateItemTxtBoxes()
Dim db As Database
Dim rsTable As Recordset
Dim qdfPara1 As QueryDef
Dim strSearchItem As String
Set db = CurrentDb
Set qdfPara1 = db.QueryDefs("QryGetItemInfo")
strSearchItem = Forms![frmInvValItemMaint]![cboItem]
qdfPara1![Forms!frmInvValItemMaint!cboItem] = strSearchItem
Set rsTable = qdfPara1.OpenRecordset()
‘This is where it errors. It doesn’t seem to be running the query and picking up the item information
Me.txtDescription.Value = rsTable![Description]
Me.txtStkUom.Value = rsTable![StockUom]
Me.txtProdClass.Value = rsTable![ProductClass]
Me.txtPartCat.Value = rsTable![PartCategory]
Me.txtDeadFlg.Value = rsTable![DeadFlag]
Me.txtSupercession.Value = rsTable![SupercessionDate]
Me.txtGrnShtCd.Value = rsTable![grnshtcode]
Me.txtLongDesc.Value = rsTable![LongDesc]
Me.txtInvSortCd.Value = rsTable![INVSORTCODE]
Me.txtInvSortCdDesc.Value = rsTable![InvSortCodeDesc]
Me.txtProfCtr.Value = rsTable![PROFITCENTER]
Me.txtProfCtrDesc.Value = rsTable![ProfitCDes]
'Me.txtLastCostChng.Value = rsTable![LastCostChgDate]
Me.txtPostDate.Value = Date
rsTable.Close
End Function
Private Function PopulateItemTxtBoxes()
Dim db As Database
Dim rsTable As Recordset
Dim qdfPara1 As QueryDef
Dim strSearchItem As String
Set db = CurrentDb
Set qdfPara1 = db.QueryDefs("QryGetItemInfo")
strSearchItem = Forms![frmInvValItemMaint]![cboItem]
qdfPara1![Forms!frmInvValItemMaint!cboItem] = strSearchItem
Set rsTable = qdfPara1.OpenRecordset()
‘This is where it errors. It doesn’t seem to be running the query and picking up the item information
Me.txtDescription.Value = rsTable![Description]
Me.txtStkUom.Value = rsTable![StockUom]
Me.txtProdClass.Value = rsTable![ProductClass]
Me.txtPartCat.Value = rsTable![PartCategory]
Me.txtDeadFlg.Value = rsTable![DeadFlag]
Me.txtSupercession.Value = rsTable![SupercessionDate]
Me.txtGrnShtCd.Value = rsTable![grnshtcode]
Me.txtLongDesc.Value = rsTable![LongDesc]
Me.txtInvSortCd.Value = rsTable![INVSORTCODE]
Me.txtInvSortCdDesc.Value = rsTable![InvSortCodeDesc]
Me.txtProfCtr.Value = rsTable![PROFITCENTER]
Me.txtProfCtrDesc.Value = rsTable![ProfitCDes]
'Me.txtLastCostChng.Value = rsTable![LastCostChgDate]
Me.txtPostDate.Value = Date
rsTable.Close
End Function