printing from a form (1 Viewer)

dutchpete

New member
Local time
Today, 19:58
Joined
Jun 12, 2001
Messages
7
hello,
i have an urgent request for help, i already spent hours on this problem but i cant figur it out.
i have a form with 4 textboxes fromdate/todate and from id to id.
on the form is also a combobox with all my reports.
this is what i want.
the user must have the possibility to select a daterange or a id range and print the selected report.
iknow that you can put the name of the textbox in the query, but i cant get it to print the right report.
please help me.
peter
 

jimbrooking

Registered User.
Local time
Today, 14:58
Joined
Apr 28, 2001
Messages
210
Unless I'm missing something, your problem is pretty straight-forward. You'd want to code the "OnClick event of a "Print" command button something like this:

If you require a from- and to-date, write

If IsNull(Me.FromDate) Then
Msgbox "Enter a From-Date for the report"
DoCmd.GotoControl "FromDate"
Exit Sub
End If
' (Repeat for To-Date)
' (Use the IsDate function to ensure that both boxes have a valid date)
' (Repeat for From-ID and To-ID)
' (Use the IsNumeric function and other diagnostics to ensure the IDs are in an allowable range)

Then just

DoCmd.OpenReport Me.ReportName,,, _
"ID >= " & Me.FromID & " AND " & _
"ID <= " & Me.ToID & " AND " & _
"FromDate >= #" & Me.FromDate & "# AND " _
"ToDate <= #" & Me.ToDate & "#"

(Pardon for syntax errors - it's early.
)

Jim
 

Users who are viewing this thread

Top Bottom