Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 22nd, 2004, 08:51 AM
BetsyBean BetsyBean is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 14 BetsyBean User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 15 sec
Reputation Power: 0
Lookup Not Working

I am attempting to use DLookup in following code. I do not get an error message
but the code will work if I actually place my username as the text. I need to have it
be a variable though. Please help. Also, thought I read something the other day that the
DLookup is not the best option anymore. What should I be using instead? Thanks.

Private Sub Form_Load()
Dim strName As String
Dim varCheck As Variant

varCheck = fOSUserName 'This is a function that does work fine
MsgBox "Username is " & varCheck 'This msgbox works fine
If varCheck <> vbNullString Then
'I am looking for the autonumber of the employee here
strName = Nz(DLookup("[PerAuto]", "tblPersonnel", "[NetworkName]= ' " & varCheck & "'"), 0)
If strName = 0 Then
DoCmd.Close "frmPayroll"
Else
Me!cboEmployee = strName
End If
Else
DoCmd.Close "frmPrePayroll"
End If
End Sub

Reply With Quote
  #2  
Old December 1st, 2004, 06:32 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 4
Hi BetsyBean,

My apologies, I missed your post. Your syntax has a space in the quotes for your criteria

strName = Nz(DLookup("[PerAuto]", "tblPersonnel", "[NetworkName]= ' " & varCheck & "'"), 0)

Remove the space in the quote after [NetworkName] to like this

strName = Nz(DLookup("[PerAuto]", "tblPersonnel", "[NetworkName]= '" & varCheck & "'"), 0)

This will get what you are looking for.

lwells

Reply With Quote
  #3  
Old December 6th, 2004, 03:16 PM
BetsyBean BetsyBean is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 14 BetsyBean User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 15 sec
Reputation Power: 0
Thanks

Thanks - that was the problem and I can't believe how much difference one space can make.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > Lookup Not Working


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway