Reputation: 1
I created a table named tblProduct with 3 fields, Product_ID (short text), Product_Name (short text), Sale_Unit (short text), Product_ID is primary key.
Then there is a form name frm_Product, with cboProductID as combo box, with the row source set to:
SELECT tblProduct.ID, tblProduct.Product_Name, tblProduct.Sale_Unit
FROM tblProduct
ORDER BY tblProduct.Product_Name;
Its bound column set to 1, column count to 3, column width to 0cm;4cm;2cm, there are then 2 textboxes, txtProduct_Name and txtSale_Unit.
Then I wrote the following code for the AfterUpdate event of cboProductID:
Private Sub cboProductID_AfterUpdate()
Set rs1 = CurrentDb.OpenRecordset("tblProduct", dbOpenDynaset, dbSeeChanges)
rs1.FindFirst "ID = '" & "Me.cboProductID.Column(0)" '"
txtProduct_Name = rs1!Product_Name
txtSale_Unit = rs1!Sale_Unit
End Sub
The code stopped at the .FindFirst
method.
Upvotes: 0
Views: 1314
Reputation: 14
Try this instead : Remove the Quotes around me.cboProdtID.Column(0)
Upvotes: 0
Reputation: 49169
Try this:
rs1.FindFirst "ID = '" & Me.cboProductID.Column(0) & "'"
if you put quotes around that expression, then you wind up search for a id of Me.cboproductID.Column(0), and I don't think that is the "id" your looking for.
Upvotes: 1