Dlookup Help

johnherrerajuan

Registered User.
Local time
Today, 15:24
Joined
Feb 25, 2013
Messages
44
Hello I have a combo box named L1 and after it is selected I want it to retrieve the hourly rate associated. After that i want it to multiply with the number of hours. I came up with this code but it will not accept the "=" in trades. I took it out and it only gives me the value of the first record instead the one assosiated with it. Can someone tell me what is wrong with this
Code:
Private Sub L1_AfterUpdate()
    L11 = DLookup("HourlyRate", "Labor", "Trades=" & hourlyrate)
  End Sub
 
Waht are...

Trades and hourlyrate

This might also help...

If ID field is numeric...
Code:
=DLookup("FieldFromTableOrQuery", "YourTableOrQuery", "[FieldFromTableOrQuery]=" & Me![FieldFromForm])
If ID field is text
Code:
=DLookup("FieldFromTableOrQuery", "YourTable", "[FieldFromTableOrQuery]='" & Me![FieldFromForm] & "'")
OR
If a Combo Box
Code:
=[ComboNameHere].[Column](PutColumnNumberHere)
…and remember Combo Boxes start with 0 not 1.
 
Waht are...

Trades and hourlyrate

This might also help...

If ID field is numeric...
Code:
=DLookup("FieldFromTableOrQuery", "YourTableOrQuery", "[FieldFromTableOrQuery]=" & Me![FieldFromForm])
If ID field is text
Code:
=DLookup("FieldFromTableOrQuery", "YourTable", "[FieldFromTableOrQuery]='" & Me![FieldFromForm] & "'")
OR
If a Combo Box
Code:
=[ComboNameHere].[Column](PutColumnNumberHere)
…and remember Combo Boxes start with 0 not 1.

I used:
Code:
=[12].[HourlyRate]
But, #Name? is the return when i typed it in on the expression builder
 
What is the name of the control? It can't be the same name as the field. And what is 12 and hourlyrate? Is 12 the Combo Box?
 
Ok
[L1] [L2]... [L12] are just combo boxes on my form that retrieve information from
Table: Labor, which have (Trades,MonthlyRate,HourlyRate) as columns.
Im using any random unbound box right now for experimenting. What i want is the value of trades(text field) to equal the number of hourly rate(number field). Let say i pick carpenter on [L1] and on the unbound box i want $300 to display, if i pick Painter then i want the value associated to display

one more thing [L11] was originally an unbound box when I posted this now its a combo box like [L1]-[L12]
 
So then shouldn't that be...

Code:
=[L12].[Column].(1)

I'm assuming Column 0 is the PK field.
 
I put it in the Expression Builder and it said Syntax Error
i put it on the Vb an it came out with a red column

There is no Primary key so i tried 0 as well
 

Users who are viewing this thread

Back
Top Bottom