Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding Problem Blah!

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
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 = &quot;Inspection Report&quot;

If [Field14] <> No Then
DoCmd.OpenReport DocName2, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If

DocName4 = &quot;Graph Report&quot;

If [Field16] <> No Then
DoCmd.OpenReport DocName3, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr

End If

DocName5 = &quot;Annual Report&quot;
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 = &quot;Cover Page&quot;

If [Field12] <> No Then
DoCmd.OpenReport DocName, A_NORMAL
pagectr = pagectr + 1
[PageNum] = pagectr
End If


DocName2 = &quot;Inspection Report&quot;
If [Field14] <> No Then
DoCmd.OpenReport DocName2, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr
End If

DocName3 = &quot;Graph Report&quot;
If [Field16] <> No Then
DoCmd.OpenReport DocName3, A_NORMAL
pagectr = pagectr + 2
[PageNum] = pagectr

End If

DocName4 = &quot;Annual Report&quot;
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
 
Hi Bill,

Code:
Dim SetData As String
    Dim pagectr As Integer
    
    SetDate = &quot;SetPrintData&quot;

Do you mean SetData in the last line here?

Regards,

Mark

 
Yes i caught that right after i posted it, I did fix that, however the error happened before it ever called for that macro. The problem i am having is getting information from one form to another using vb, i am not all that good in vb and can do a few things so i used a macro to set the value and ran that with vb. Using vb how can you get a value from a field on one form and place it in another form i guess is the real question here. Every thing i have tried has not seemed to work.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top