Dlookup function in VBA

wdenboer

Registered User.
Local time
Today, 23:38
Joined
Feb 4, 2009
Messages
14
Hi all,

I am working on a part of a database but something is going wrong with my Dlookup function.

I have a form called FST_main. On this form is an option group called "OG_status". The selected value in OG_status is used for a Dlookup is a table called "status".
On the same form is textbox "Sel_st" which should return the corresponding value from the table (when the command button is clicked).

I used VBA for this because in a later stage I'd like the use the return values from Dlookup as a query criteria.

Code:
    Dim strS_select As Variant
           
    strS_select = Me.OG_status
    Me.Sel_st = DLookup("[Status]", "Status", "[Status ID] = strS_select")
As a return I only get "you canceled the previous operation"

Can somebody help me with this.
 
Should be

Me.Sel_st = DLookup("[Status]", "Status", "[Status ID] = " & strS_select)
 
Tnx DCrake,

works fine now. Did try this solution before, but somehow it didn't work at that time. Probably there was a second error in the code.

thanks a lot
 

Users who are viewing this thread

Back
Top Bottom