Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup problem

Status
Not open for further replies.

jonnj

Programmer
Jun 20, 2003
29
US
I have a data entry form that I want to populate the age field automatically when the (field) last name(after update event) is entered ( previously in table).

I have used this dlookup:
DLookup("age", "general info", "[Age] = '" & Me.Age).

This bombs. I have tried some many variations I've lost count. I had some code that populated the field but with the wrong age. Ive been unable to replicate it. I have used brackets, not used them. All the same result.

Table: general info
field to fill: age

It seems the 3rd part of the dlookup is the problem.

Any Suggestions or solutions greatly appreciated.

Thx John
 
How are ya jonnj . . .

Assuming age is numeric ... drop the single quote:
Code:
[blue]DLookup("age", "general info", "[Age] = [COLOR=red yellow]'[/color]" & Me.Age)[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 

I agree with Duane... you are looking up an age based on an age you already have. The only reason I can think of for doing this would be to check for duplicates.

Maybe you want:

Code:
DLookup("age", "general info", "Last Name = '" & Me.LastName & "'")

And... do you really have spaces in your table names? 'General Info' (with a space) can cause you headaches later.
 
I think Gammachaser has just intentionally demonstrated the inappropriateness of spaces since the expression he used wouldn't work because of a space.

I'll leave it to the readers to find and/or correct the ill-advised name.

Duane
Hook'D on Access
MS Access MVP
 
Gammachaser, your solution work perfectly.
Thanks very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top