Ok here is the code:
Private Sub Command293_Click()
'On Error GoTo Err_Command293_Click
Dim DocName As String
Dim DocName2 As String
Dim DocName3 As String
Dim DocName4 As String
Dim DocName5 As String
Dim LinkCriteria As String
Dim SetData As String
Dim pagectr As Integer
SetDate = "SetPrintData"
DocName = "Inspection Report Selection Form"
DoCmd.OpenForm DocName, acNormal, , , , acWindowNormal, LinkCriteria
pagectr = 1
[PageNum] = pagectr
DoCmd.RunMacro SetData, 1
DocName2 = "Cover Page"
If [Field12] <> No Then
DoCmd.OpenReport DocName, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
DocName3 = "Inspection Report"
If [Field14] <> No Then
DoCmd.OpenReport DocName2, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName4 = "Graph Report"
If [Field16] <> No Then
DoCmd.OpenReport DocName3, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName5 = "Annual Report"
If [Field18] <> No Then
DoCmd.OpenReport DocName4, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
'Err_Command293_Click:
'MsgBox Err.Description
'Resume Exit_Command293_Click
End Sub
I get the error Microsoft Blah Blah cant find the Field '|' referred to in your expression.
Now i have used a portion of the code above in another command button which is as follows:
Private Sub Command31_Click()
On Error GoTo Err_Command31_Click
Dim pagectr As Integer
pagectr = 1
[PageNum] = pagectr
Dim DocName As String
Dim DocName2 As String
Dim DocName3 As String
Dim DocName4 As String
DocName = "Cover Page"
If [Field12] <> No Then
DoCmd.OpenReport DocName, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
DocName2 = "Inspection Report"
If [Field14] <> No Then
DoCmd.OpenReport DocName2, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName3 = "Graph Report"
If [Field16] <> No Then
DoCmd.OpenReport DocName3, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName4 = "Annual Report"
If [Field18] <> No Then
DoCmd.OpenReport DocName4, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
Exit_Command31_Click:
Exit Sub
Err_Command31_Click:
MsgBox Error$
Resume Exit_Command31_Click
End Sub
When this is ran i have not gotten any errors. When i tried to combine this code with code from another button is when i got the error in this line.
[PageNum] = pagectr
Any Ideas?
Bill
Private Sub Command293_Click()
'On Error GoTo Err_Command293_Click
Dim DocName As String
Dim DocName2 As String
Dim DocName3 As String
Dim DocName4 As String
Dim DocName5 As String
Dim LinkCriteria As String
Dim SetData As String
Dim pagectr As Integer
SetDate = "SetPrintData"
DocName = "Inspection Report Selection Form"
DoCmd.OpenForm DocName, acNormal, , , , acWindowNormal, LinkCriteria
pagectr = 1
[PageNum] = pagectr
DoCmd.RunMacro SetData, 1
DocName2 = "Cover Page"
If [Field12] <> No Then
DoCmd.OpenReport DocName, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
DocName3 = "Inspection Report"
If [Field14] <> No Then
DoCmd.OpenReport DocName2, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName4 = "Graph Report"
If [Field16] <> No Then
DoCmd.OpenReport DocName3, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName5 = "Annual Report"
If [Field18] <> No Then
DoCmd.OpenReport DocName4, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
'Err_Command293_Click:
'MsgBox Err.Description
'Resume Exit_Command293_Click
End Sub
I get the error Microsoft Blah Blah cant find the Field '|' referred to in your expression.
Now i have used a portion of the code above in another command button which is as follows:
Private Sub Command31_Click()
On Error GoTo Err_Command31_Click
Dim pagectr As Integer
pagectr = 1
[PageNum] = pagectr
Dim DocName As String
Dim DocName2 As String
Dim DocName3 As String
Dim DocName4 As String
DocName = "Cover Page"
If [Field12] <> No Then
DoCmd.OpenReport DocName, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
DocName2 = "Inspection Report"
If [Field14] <> No Then
DoCmd.OpenReport DocName2, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName3 = "Graph Report"
If [Field16] <> No Then
DoCmd.OpenReport DocName3, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If
DocName4 = "Annual Report"
If [Field18] <> No Then
DoCmd.OpenReport DocName4, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If
Exit_Command31_Click:
Exit Sub
Err_Command31_Click:
MsgBox Error$
Resume Exit_Command31_Click
End Sub
When this is ran i have not gotten any errors. When i tried to combine this code with code from another button is when i got the error in this line.
[PageNum] = pagectr
Any Ideas?
Bill