Jumat, 23 September 2011

RE: [MS_AccessPros] Dlookup error

Art,
One of the most difficult but important understandings when creating code and expressions in Access (or other languages) is how to work with various data types and their delimiters.

Bottom line:
text/strings require single or double quotes as delimiters
numbers require no delimiters
dates in Access reqire "#" delimiters

Me.txtEmployeeName = DLookup("[First Name]", "[tblEmployee]", "[EmployeeID]=" & glngThisEmpID )

Duane Hookom
MS Access MVP

To: MS_Access_Professionals@yahoogroups.com
From: dbalorenzini@yahoo.com
Date: Fri, 23 Sep 2011 08:01:42 -0700
Subject: Re: [MS_AccessPros] Dlookup error


Actually I got this to work and you are correct about the quotes:

glngThisEmpID = DLookup("[EmployeeID]", "[tblSecurity]", "[UserID]='" & Forms![Login]![txtUser] & "'")

So now what I am trying to do is load my employee first name into a text box on my Home screen for a Welcome message.

I am trying to do this but I am gettign a data type mismatch:

Me.txtEmployeeName = DLookup("[First Name]", "[tblEmployee]", "[EmployeeID]='" & glngThisEmpID & "'")

glngThisEmpID is defined as a integer.

any ideas?

With warm regards,

Arthur Lorenzini| SQL Server/Access Developer l alorenzin@live.com
Office: 605-338-0947| Mobile: 605-857-9137 | Fax: 605-338-0947

1316 E. 7th Street
Sioux Falls, SD 57103
SQL Server Development
Database Adminstration Services
Microsoft Access Development
Grant Writing TA Services
IT Assessment Services
Software Application Training

From: Liz Ravenwood <liz_ravenwood@beaerospace.com>
To: "'MS_Access_Professionals@yahoogroups.com'" <MS_Access_Professionals@yahoogroups.com>
Sent: Friday, September 23, 2011 9:56 AM
Subject: RE: [MS_AccessPros] Dlookup error


Art,

Do you need to delimit it with quote marks?

glngThisEmpID = DLookup("[EmployeeID]", "tblSecurity", _
"[UserID] = '" & gstrThisUser & "'")

Liz Ravenwood
Database Developer / Programmer
Super First Class Products
B/E Aerospace
O: 1.520.239.4808
www.beaerospace.com

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Art
Sent: Friday, September 23, 2011 7:46 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Dlookup error

I have the following code:
gstrThisUser = Me.txtUser
glngThisEmpID = DLookup("[EmployeeID]", "tblSecurity", _
"[UserID] = " & gstrThisUser)

The issue is this is erroring with the following message:

Run-time error 2471
The expression yu entered as a query parameter produced this error: 'svogel'

I am trying to return the employeeid based on the lookup:

UserID is a string
gstrThisUser is a string

What am I doing wrong?

Thank you

Art Lorenzini
Sioux Falls, Sd

------------------------------------

Yahoo! Groups Links

This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

[Non-text portions of this message have been removed]


[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/MS_Access_Professionals/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/MS_Access_Professionals/join
(Yahoo! ID required)

<*> To change settings via email:
MS_Access_Professionals-digest@yahoogroups.com
MS_Access_Professionals-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
MS_Access_Professionals-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Tidak ada komentar:

Posting Komentar