date range pop up box for report

M

Mary Beth

I have created a report to return data such as 'Total Referrals' in a date
range. I borrowed the attached VBA code from a collegue and tweeked it for
my use, but now don't know how to create the pop up box to enter your 'Start
date' and End Date'. Could someone help me with this problem?

Private Sub getSQL(myStartDate As Date, myEndDate As Date)
Dim sSQL As String
Me.Text1.Caption = "Reporting Period: " & myStartDate & " to " & myEndDate

sSQL = _
"SELECT Count(ConsumerID) AS TotalofConsumerID FROM qryConsumerApps
WHERE dtmReferralDt>=#" _
& myStartDate & "# AND dtmReferralDt<=#" & myEndDate & "#"
Me.Text2.Caption = getNumber(sSQL)

etc, etc.....

Thanks in advance
 
J

JackPoland

At the begining of this Sub add this:

MyStartDate = InputBox("Enter start date", "Date")
MyEndDate = InputBox("Enter end date", "Date", Now())
 
M

Mary Beth

Thanks for this code. However, I put it in my code as follows, closed the
report, re-opened it and nothing pops up. It doesn't seem to be working, do
you know what might be wrong?

Private Sub getSQL(myStartDate As Date, myEndDate As Date)
myStartDate = InputBox("Enter Start Date", "Date")
myEndDate = InputBox("Enter End Date", "Date", Now())

Dim sSQL As String
Me.Text1.Caption = "Reporting Period: " & myStartDate & " to " & myEndDate

etc....
 
C

Cheese_whiz

Hi Mary,

Is 'Text1' a text field or a label? If it's a text field, it doesn't have a
'caption' property.

CW
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top