Help with report

M

myxmaster

Using the following code behind a form called frm reports I am able to
find records by any date, week, month and year. As you can see the
data is derived from a report called transaction report. The
transaction report is based on a query with "Credit" set as the
criteria. I have 4 different criteria that I need to run the same
report from, "Credit", "Check", "Cash", "Other". As my programmig
skills are limited the only way I can achieve this is by making 4
different queries, reports and forms. I was wondering is there a way
to place an option box on the form with the above options and run the
report based on the selected option.? Simply put I choose cash, select
my dates and voila!.
TIA

Private Sub cmdtoday_Click()
'Sets the Date From and Date To text boxes
'to Today's Date

Me!txtdatefrom = Date - 1
Me!txtDateTo = Date - 1

End Sub

Private Sub cmdweek_Click()
'Sets the Date From and Date To text boxes
'to show complete working week (Mon - Sun)

Dim today

today = Weekday(Date)

Me!txtdatefrom = DateAdd("d", (today * -1) + 2, Date)
Me!txtDateTo = DateAdd("d", 8 - today, Date)

End Sub

Private Sub cmdmonth_Click()
'Sets the Date From and Date To text boxes
'to show complete month (from start to end of current month)

Me!txtdatefrom = DateSerial(Year(Date), Month(Date), 1)
Me!txtDateTo = DateSerial(Year(Date), Month(Date) + 1, 0)

End Sub

Private Sub cmdyear_Click()
'Sets the Date From and Date To text boxes
'to show complete current year

Me!txtdatefrom = CDate("01/01/" & Year(Date))
Me!txtDateTo = DateAdd("d", -1, DateAdd("yyyy", 1, Me!
txtdatefrom))

End Sub
Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim stDocName As String

stDocName = "transactionrpt"

'Check values are entered into Date From and Date To text boxes
'if so run report or cancel request

If Len(Me.txtdatefrom & vbNullString) = 0 Or Len(Me.txtDateTo &
vbNullString) = 0 Then
MsgBox "Please ensure that a report date range is entered into
the form", _
vbInformation, "Required Data..."
Exit Sub
Else
DoCmd.OpenReport stDocName, acPreview
End If
Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub
 

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