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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

primary key lookup using dlookup 1

Status
Not open for further replies.

rhinomac

Programmer
Jan 24, 2003
34
US
I have Me!fields from a form that im adding to diffrent tables. I want to be able to look up a Me!techname in the technician table and find its corresponding tech_id number(primarykey) and write that primary key to a diffrent table Tech status
-table is technician
-primary key field is tech_id
-other field is techname


.Open "techstatus", CurConn, , , adCmdTableDirect
.AddNew
![serial_no_] = (Me!serial_no_)
![number] = (Me!number)

Dim varX As Variant
varX = (DLookup("[technician]", "Technician", "[tech_id] = " _& Forms!hotswapevent!lm_updated_by_lastname))
.Update
.Close
Any help would be greatly appreciated...Or another method suggestion if d lookup is not suitable..The error im getting on the way it is set up now is
-Run time error 2001
You cancelled the previous operation
-errors out on the dlookup line
 

if Forms!hotswapevent!lm_updated_by_lastname is a string:

varX = DLookup("[technician]", "Technician", "[tech_id] = '" _& Forms!hotswapevent!lm_updated_by_lastname+"'")

note single quotes added to indicate this is a string value to the SQL processor.
I am a little confused by the error message, which is not appropriate for this error, so you may have something else wrong

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top