chuckcoleman
Registered User.
- Local time
- Today, 05:38
- Joined
- Aug 20, 2010
- Messages
- 363
Dim MgrEmailX As String
MgrEmailX = DLookup("[MgrEmail]", "[Admin Table]")
MsgBox ("This from the Employee Form: " & DLookup("[Email]", "[Employee Table]", "[EMail] = [COLOR="Red"]'" & MgrEmailX & "'")[/COLOR])
Dim MgrEmailX As String
MgrEmailX = DLookup("[MgrEmail]", "[Admin Table]")
msgbox "Manager EMail to look up is " & MgrEmailX ' Make sure you have one to begin with.
Dim EmailX As String
EmailX = DLookup("[Email]", "[Employee Table]", "[EMail] = '" & MgrEmailX & "'")
MsgBox ("This from the Employee Form: " & EMailX )
MsgBox ("This from the Employee Form: " & DLookup("[Email]", "[Employee Table]", "[MgrEMail] = '" & MgrEmailX & "'"))
Mark,
Before I asked for help, I tested via the DIM statement to make sure I could see the MgrEmailX in a MsgBox. That worked.
I also copied the matching email from the [Employee Table] to the [Admin Table] to make sure they were perfect matches. Still didn't work.
I then took your suggestion and added the second DIM statement EMailX = DLookup("", "[Employee Table]", "[EMail] = '" & MgrEmailX & "'") and used EMailX in the message box AND IT WORKED!
Thank you. It took declaring it to make it work. I appreciate your help.
Chuck[/QUOTE]
Please note, that SHOULDN'T have fixed your issue, at least not in a logical manner. Then again I've found that occasionally ACCESS isn't all that logical in how things are presented.
My best guess would be that MsgBox is expecting nothing more than what is to be displayed to be passed to it, so it isn't actually firing off the DLookup. Due to how I code, I tend to avoid passing the return from a function as part of the parameters I pass to other functions. I normally have a firmly declared variable I hold the value in, just to make sure I'm not passing bad values to functions.
Maybe ACCESS is just upset you didn't sacrifice a chicken to it prior to coding?
? msgbox("Test : " & dlookup("Data","Lookups","Data = 'Teresa Hawkins'"))
? msgbox("Test : " & dlookup("Data","Lookups","Data = 'Teresa Hawkins' AGG"))
If IsNull(EmailX = DLookup("[Email]", "[Employee Table]", "[EMail] = '" & MgrEmailX & "'")) Then
EmailX = "XYZ"
Else
EmailX = EmailX = DLookup("[Email]", "[Employee Table]", "[EMail] = '" & MgrEmailX & "'")
End If
EmailX = NZ(DLookup("[Email]", "[Employee Table]", "[EMail] = '" & MgrEmailX & "'"),"XYZ")
MgrEmailX = DLookup("[MgrEmail]", "[Admin Table]")