PC Review


Reply
Thread Tools Rate Thread

DLookup Syntax for text criteria

 
 
bymarce
Guest
Posts: n/a
 
      12th Feb 2009
I have a form called "WorkAssignments" on which my user can enter or look up
wokr assignments. I have a button that I want to send a filtered report
based on the initials of the person to whom the work was assigned and the
date on which it was assigned. I have a table called "Personel" that
contains first and last names, initials, and email addresses. I want to look
up the email addres in the "Personel" table based on the initials in the
unbound control "fAssignedTo" on the form. "fAssigned" to is used for
filtering the form. When I try to run this code it says "Invalid use of
Null" and highlights the Dlookup statement. How do I fix it?
Marcie

Dim SendTo As String
SendTo = DLookup("[Email]", "Personel", "[Initials] = ""Me.fAssignedTo""")
Dim strWhere As String
If Me.FilterOn Then
strWhere = Me.Filter
End If
Debug.Print strWhere

Dim MySubject As String, MyMessage As String
SendTo = Mail
MySubject = Me.MLO
MyMessage = "Please complete the following tests for " & Me.MLO & "."
DoCmd.SendObject acSendReport, "rptWorkAssignments", , SendTo, , ,
MySubject, MyMessage, False

 
Reply With Quote
 
 
 
 
RonaldoOneNil
Guest
Posts: n/a
 
      12th Feb 2009
SendTo = DLookup("[Email]", "Personel", "[Initials] = '" & Me.fAssignedTo &
"'")

"bymarce" wrote:

> I have a form called "WorkAssignments" on which my user can enter or look up
> wokr assignments. I have a button that I want to send a filtered report
> based on the initials of the person to whom the work was assigned and the
> date on which it was assigned. I have a table called "Personel" that
> contains first and last names, initials, and email addresses. I want to look
> up the email addres in the "Personel" table based on the initials in the
> unbound control "fAssignedTo" on the form. "fAssigned" to is used for
> filtering the form. When I try to run this code it says "Invalid use of
> Null" and highlights the Dlookup statement. How do I fix it?
> Marcie
>
> Dim SendTo As String
> SendTo = DLookup("[Email]", "Personel", "[Initials] = ""Me.fAssignedTo""")
> Dim strWhere As String
> If Me.FilterOn Then
> strWhere = Me.Filter
> End If
> Debug.Print strWhere
>
> Dim MySubject As String, MyMessage As String
> SendTo = Mail
> MySubject = Me.MLO
> MyMessage = "Please complete the following tests for " & Me.MLO & "."
> DoCmd.SendObject acSendReport, "rptWorkAssignments", , SendTo, , ,
> MySubject, MyMessage, False
>

 
Reply With Quote
 
Daniel Pineault
Guest
Posts: n/a
 
      12th Feb 2009
Change the

SendTo = DLookup("[Email]", "Personel", "[Initials] = ""Me.fAssignedTo""")

To

SendTo = DLookup("[Email]", "Personel", "[Initials] = '"Me.fAssignedTo"'")

Single quote rather than double.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"bymarce" wrote:

> I have a form called "WorkAssignments" on which my user can enter or look up
> wokr assignments. I have a button that I want to send a filtered report
> based on the initials of the person to whom the work was assigned and the
> date on which it was assigned. I have a table called "Personel" that
> contains first and last names, initials, and email addresses. I want to look
> up the email addres in the "Personel" table based on the initials in the
> unbound control "fAssignedTo" on the form. "fAssigned" to is used for
> filtering the form. When I try to run this code it says "Invalid use of
> Null" and highlights the Dlookup statement. How do I fix it?
> Marcie
>
> Dim SendTo As String
> SendTo = DLookup("[Email]", "Personel", "[Initials] = ""Me.fAssignedTo""")
> Dim strWhere As String
> If Me.FilterOn Then
> strWhere = Me.Filter
> End If
> Debug.Print strWhere
>
> Dim MySubject As String, MyMessage As String
> SendTo = Mail
> MySubject = Me.MLO
> MyMessage = "Please complete the following tests for " & Me.MLO & "."
> DoCmd.SendObject acSendReport, "rptWorkAssignments", , SendTo, , ,
> MySubject, MyMessage, False
>

 
Reply With Quote
 
bymarce
Guest
Posts: n/a
 
      12th Feb 2009
Thanks. This fixed my problem.

"RonaldoOneNil" wrote:

> SendTo = DLookup("[Email]", "Personel", "[Initials] = '" & Me.fAssignedTo &
> "'")
>
> "bymarce" wrote:
>
> > I have a form called "WorkAssignments" on which my user can enter or look up
> > wokr assignments. I have a button that I want to send a filtered report
> > based on the initials of the person to whom the work was assigned and the
> > date on which it was assigned. I have a table called "Personel" that
> > contains first and last names, initials, and email addresses. I want to look
> > up the email addres in the "Personel" table based on the initials in the
> > unbound control "fAssignedTo" on the form. "fAssigned" to is used for
> > filtering the form. When I try to run this code it says "Invalid use of
> > Null" and highlights the Dlookup statement. How do I fix it?
> > Marcie
> >
> > Dim SendTo As String
> > SendTo = DLookup("[Email]", "Personel", "[Initials] = ""Me.fAssignedTo""")
> > Dim strWhere As String
> > If Me.FilterOn Then
> > strWhere = Me.Filter
> > End If
> > Debug.Print strWhere
> >
> > Dim MySubject As String, MyMessage As String
> > SendTo = Mail
> > MySubject = Me.MLO
> > MyMessage = "Please complete the following tests for " & Me.MLO & "."
> > DoCmd.SendObject acSendReport, "rptWorkAssignments", , SendTo, , ,
> > MySubject, MyMessage, False
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax problem for text criteria to filter a report vavroom@gmail.com Microsoft Access 8 30th May 2008 04:44 AM
DLookUp syntax help please =?Utf-8?B?SldDcm9zYnk=?= Microsoft Access Reports 6 18th May 2007 10:56 PM
Dlookup Syntax =?Utf-8?B?bWFudmVlcg==?= Microsoft Access Form Coding 1 18th Apr 2005 12:44 PM
Dlookup Syntax Help =?Utf-8?B?Y3ZlZ2Fz?= Microsoft Access Form Coding 5 29th Dec 2004 11:09 PM
Proper syntax for DLookup criteria George Microsoft Access Queries 2 20th Mar 2004 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:44 PM.