Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 26th, 2006, 07:31 AM
Registered User
 
Join Date: Sep 2006
Location: Glasgow, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dlookup and variables

I am attemting to pass a variable field name to strFldNm but the dlookup returns the value held in strFldNm instead of the value in the field by that name

strFldNm="db_Access"

varVal = DLookup("['" & strFldNm & "']", "tblUsers", "[userName]='" & Forms!frmMain!Combo10 & "'")

varVal="db_Access" INSTEAD OF "-1"

What have I got wrong?
Reply With Quote
  #2 (permalink)  
Old September 26th, 2006, 09:07 AM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Jaqx,
Does the dlookup work if you use the actual field name vs the variable?

Kevin

dartcoach
Reply With Quote
  #3 (permalink)  
Old September 29th, 2006, 03:28 AM
Registered User
 
Join Date: Sep 2006
Location: Glasgow, , United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I can construct a string with the field name proper in place, but the whole point is that I thought that I might to be able to construct the string with the field name itself as a variable. That way one standard DLOOKUP string in this instance could be used on any field of choice without having to construct a string per field.
Reply With Quote
  #4 (permalink)  
Old September 29th, 2006, 06:47 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Does this matter?

This:
varVal = DLookup("['" & strFldNm & "']", "tblUsers", "[userName]='" & Forms!frmMain!Combo10 & "'")

Should be:
varVal = DLookup("['" & strFldNm & "']", "tblUsers", "[userName]='" & [Forms]![frmMain].[Combo10] & "'")


mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with DLookup Devilboy13 Access VBA 4 August 30th, 2006 02:48 PM
Help - Dlookup function kk_sg Access VBA 3 August 23rd, 2006 11:30 AM
DLookup Teqlump Access VBA 1 August 9th, 2006 11:48 PM
Dlookup with If ..Then ..Else and Chkboxes ecampos Access VBA 1 August 19th, 2005 01:51 PM
Dlookup with If ..Then ..Else and Chkboxes ecampos Access 16 August 18th, 2005 08:08 AM



All times are GMT -4. The time now is 09:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.