Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This site is like first coffee in the winter morning..."

Geography

Where in the world do Tek-Tips members come from?
vba317 (Programmer)
23 Jul 12 12:18
I am trying to implement a dlookup command from the on enter event

The form name is frmServiceCalls
The Table name is tblAQM1data that I am getting the data from
The name of the of the text box on the form if txtSerialNumber
I am trying to populate a textbox called txtHospitalname on the form frmServiceCalls
I am not getting a error but the textbox hospitalname is not populating


I am using the following code

[code]

variable = DLookup("txtHospitalName", "TblAQM1Data", "[txtSerialNumber]=Forms![frmServiceCalls]!.[SerialNumber]")


[Code]


missinglinq (Programmer)
23 Jul 12 14:34
The part in Red is supposed to be the name of the Field in the Table, while the part in Blue is supposed to to be the name of the Control in the Form.

"[txtSerialNumber]=Forms![frmServiceCalls]!.[SerialNumber ]")

Given the names, it would appear as if you have reversed these.

This syntax is only valid of SerialNumber is defined as a Number Datatype. A Text Datatype Field would require different syntax.

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

vba317 (Programmer)
23 Jul 12 15:10
Thank you I did try it and I still got a null value.

[Code]

Dim Hospital1 As String


Hospital1 = DLookup("[txtHospitalName]", "TblAQM1Data", "[SerialNumber]= Forms![frmServiceCalls]![txtSerialNumber]")


[\Code]

dhookom (Programmer)
23 Jul 12 15:14
Missinglinq has the main issue. You also have "!." which is wrong. Try either

CODE

variable = DLookup("txtHospitalName", "TblAQM1Data", "[SerialNumber]=" & Forms![frmServiceCalls]![txtSerialNumber]) 
or if SerialNumber is text

CODE

variable = DLookup("txtHospitalName", "TblAQM1Data", "[SerialNumber]=""" & Forms![frmServiceCalls]![txtSerialNumber] & """") 

Duane
Hook'D on Access
MS Access MVP

Helpful Member!  missinglinq (Programmer)
23 Jul 12 15:36
That was a good catch, Duane! I'm looking at a laptop from about 8 feet away and missed the dot-after-the-bang!

I meant to add, for the OPs benefit, that the

Forms![frmServiceCalls]![txtSerialNumber]

could be be replaced with

Me.txtSerialNumber

and the kind of mistakes frequently encountered when using full referencing could be avoided.

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close