Kamis, 22 Oktober 2015

Re: [MS_AccessPros] VBA with SQL code error question

 

Duane,

That was it. Thank You Very Much.

 
Jim Wagner



On Thursday, October 22, 2015 3:23 PM, "Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


 
Jim,
 
You are using parameter prompts, not form text boxes. IMO, this isn't good user interface.
 
strSQL = "SELECT DISTINCT ContactName, Email " & _
    "From Events " & _
    "WHERE PickupDt Between #" & Me.txtStartDate & "# AND #" & Me.txtEndDate & "# "
    "GROUP BY ContactName, Email, PickupDt"
 
Duane Hookom MVP
MS Access
 

Date: Thu, 22 Oct 2015 14:48:39 -0700
Subject: [MS_AccessPros] VBA with SQL code error question
Hello all,

I have code that is to email the users from a sql code. For some reason the code works If I leave off the form reference as the Between criteria in the query the sql statement.

Here is the sql statement in the vba
strSQL = "SELECT DISTINCT Events.ContactName, Events.Email From Events GROUP BY Events.ContactName, Events.Email, Events.PickupDt HAVING (((Events.PickupDt) Between [Enter start date] And [Enter End date]));"

I get an error message which states
Run-time error 3061
Too few parameters. Expected 2.

If I take out the having part it works with this below.
strSQL = "qryEventDistributionEmailList"

this query has the criteria typed as Between #10/1/2015# And #10/11/2015# and it works.
How do I reference in the sql statement in vba to look at the form text boxes.

Thank You
Jim Wagner
 


__._,_.___

Posted by: Jim Wagner <luvmymelody@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

.

__,_._,___

Tidak ada komentar:

Posting Komentar