Northwind PrintSalesReports

pgsibson

Registered User.
Local time
Today, 22:13
Joined
Jan 24, 2008
Messages
44
HI Everyone

I am trying to copy the above dialog form to make selections for reports. Unfortunately Access 2003 seems to have diffferent soded and will not allow the If Is Null lines with a compile "expected end of statement" error. I have tried different methods of specifiying the condition with no effect.

Here is the current version that does not work
Sub PrintReports(PrintMode As Integer)
On Error GoTo Err_Preview_Click
'This procedure used in Preview_Click and Print_Click Sub Procedures.
'Preview or print report selected in the SelectOptions Option Group
'Then close the QueryPIScreen Dialog form

Dim strWhereDirectorate As String
Dim strWhereDepartment As String
Dim strWhereOwner As String


strWhereDirectorate = "Directorate=Forms![QueryPIScreen]!SelectDirectorate"
strWhereDepartment = "Department =Forms![QueryPIScreen]!SelectDepartment"
strWhereOwner = "Owner=Forms![QueryPIScreen]!SelectOwner"

With Forms!QueryPIScreen
Select Case Me!SelectOption.Value
Case 1
.DoCmd.OpenReport "SelPINotRequired", PrintMode
Case 2
.DoCmd.OpenReport "SelPIreadyNotApproved", PrintMode
Case 3
. if IsNull "Forms![QueryPIScreen]!SelectDirectorate" then
DoCmd.OpenReport "LeafletsByDirectorate", PrintMode
Else
DoCmd.OpenReport "LeafletsByDirecotrate", PrintMode, , strWhereDirectorate
End If
Case 4
.If IsNull "Forms![QueryPIScreen]!SelectDepartment" then DoCmd.OpenReport "LeafletsByDepartment", PrintMode
Else
DoCmd.OpenReport "LaafletsByDepartment", PrintMode, , strWhereDepartment
End If
Case 5
.if IsNull "Forms[QueryPIScreen]!SelectOwner" then
DoCmd.OpenReport "LeafletsByOwner", PrintMode
Else
DoCmd.OpenReport "LeafletsByOWner", PrintMode, , strWhereOwner
End If
End Select
End With
DoCmd.Close acForm, "QueryPIScreen"

Exit_Preview_Click:
Exit Sub

Err_Preview_Click:
Resume Exit_Preview_Click
End Sub

Also even thesimple coding for cases 1 and 2 does not seem to work with the Preview and Print command buttons?

Any ideas?

Regards :confused:
 
Okay here's a bit of a list of what's wrong with your code:

1. .DoCmd.OpenReport "SelPINotRequired", PrintMode
a. You don't need the period in front of DoCmd
b. PrintMode is not a valid option
c. The syntax is this:
DoCmd.OpenReport "SelPINotRequired", acViewNormal
2. Don't put periods in front of and IF statement
3. Your IsNull has to check a field or control:
IF IsNull(Me!YourFieldNameHere) Then
IF IsNull(Forms!YourFormNameHere.YourControlNameHere) Then

There is possibly more but hopefully that will get you started.
 
Northwind PrintSales Reports

Thanks Bob
So quick to reply.
That certainly did something. Selecting the first cases 1 and 2 after removing the full stops and printmode now, after selecting those options cause the report to print. BUT The Sub PrintReports in Northwind allowed selection of different reports and then by clicking either of two command buttons could print or preview by calling PrintReports with "PrintReports acPreview" or "PrintReports acNormal" .
I can no longer do this ?
What next?
Regards:confused:
 
Query Patient Information Screen

Hi Everyone (Bob)

The code posted previously is basically the code behind "Query Patient Information" Bob has got it working but after making a selection the Preview prints and does not preview? The select by date is not functioning yet, haven't written the code.
Any ideas?
Regards :confused:
 

Attachments

Users who are viewing this thread

Back
Top Bottom