VB error updating text box from combobox selection

k_c_morrissey

Registered User.
Local time
Today, 07:56
Joined
Apr 15, 2005
Messages
13
I have a combobox selection ('product description') in my orders form which when updated must populate the product_id field.

The combo box displays both fields, but once the user selects the item then the value of the combo is set to the product description and the product ID field should automatically be populated.

Once this works I will want the other fields in the record to update - do I do each field the same as product_id or can I do a requery for the who record

I am using the Dlookup function (maybe the wrong thing) as it seems to do the same thing in the Northwind sample database.

this is the before and after update code :-
Code:
___________________________________________________________________________________
Private Sub comboCatagory_ID_BeforeUpdate(Cancel As Integer)

REM BEFORE UPDATE on 1st combo ALL WORKS - included for info only 
REM sets the RowSource for problem combo

Dim sProd_description As String
    sProd_description = "SELECT products_table.product_id, products_table.prod_description " & _
        "FROM products_table " & _
            "WHERE products_table.prod_catagoryID = " & "'" & Me.comboCatagory_ID.Column(0) & "'"
    Me.comboProd_description.RowSource = sProd_description
End Sub
___________________________________________________________________________________
Private Sub comboProd_description_AfterUpdate()

REM  THIS IS THE BIT THAT IS BROKEN

    Dim strFilter As String
    comboProd_description.Value = comboProd_description.Column(1)
    strFilter = "product_id =" & comboProd_description.Column(0)
    Me!product_id = DLookup("product_id", "product_table" strFilter)
Me.product_id.Requery
End Sub
[end code]

This generates the following error when the item is selected from the list:
     Run-time error 3075
     Syntax error (missing operator) in queryexpression 'product_id'


Note: Once this works I will want the other fields in the record to update - do I do each field the same as product_id or can I do a requery for the whole record

Any help greatfully accepted.

Thx
     Kev.
 

Users who are viewing this thread

Back
Top Bottom