Auto fill from cboBOX

Stephanie T.

Registered User.
Local time
Today, 09:39
Joined
Jun 20, 2002
Messages
60
OK, I have been looking at other posts and using some of the suggestions there. Unfortunately, the ones that seem to answer my needs have problems, but are so old I don’t think it appropriate to contact the posters now. So here goes…

I have a table called tblProducts. I then have a form called frmSalesInfo where one can pick a product name from a combo box populated by the product names from tblProducts. This combo box is called cboProductName. The next text box is where I would like the UPC code to auto fill based on the chosen Product Name. The UPC code is the primary key in tblProducts. Since the columns in the query builder for the combo box have the UPC code first and the Product Name second I have put an After Update event of:

Me.(ProductUPC) = Me.cboProductName.Column(0)

I keep getting a message that Access cannot find the macro Me and it or its group does not exist. Perhaps there is a problem with the code? Perhaps I have not created a proper relationship? Do I need to write a macro?

Any help would be greatly appreciated.
Stephanie T.
 
Stephanie:

Me.ProductUPC = Me.cboProductName.Column(0)

It looks OK (except for the parentheses).

Wayne
 
Me.(ProductUPC) << those parenthesis dont look to good :D

From what i am aware of and still learning you cant have ( & ) after the "Me."
________
Ford interceptor picture
 
Last edited:
Thank you for the input. It still didn't work, but I used DLookup and now it is working great!! All fixed.

Just in case anyone is interested here is my code for that (I actually have two items it is looking up):

Private Sub ProductName_AfterUpdate()
On Error GoTo Err_ProductName_AfterUpdate

Dim strFilter As String

' Evaluate filter before it's passed to DLookup function.
strFilter = "ProductName = '" & Me!ProductName & "'"

' Look up product's upc and assign it to upc control.
Me!UPC = DLookup("UPC", "tblProducts", strFilter)

' Look up product's case price and assign it to CasePrice control.
Me!CasePrice = DLookup("CasePrice", "tblProducts", strFilter)


Exit_ProductName_AfterUpdate:
Exit Sub

Err_ProductName_AfterUpdate:
MsgBox Err.Description
Resume Exit_ProductName_AfterUpdate

End Sub


Thanks again,
Stephanie T.
 

Users who are viewing this thread

Back
Top Bottom