Automation Error

J

Jennie

This is probably a stupid question, but why is it that if I use a code for
the OnClick event of a command button it works perfect, but if I try to apply
the same code on a different button I get an automation error (I change the
control names and everything to match the other button) but it still doesn't
work. Any ideas?
 
J

Jennie

First Button:

Private Sub CurrentTransaction_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[IDNo] = " & Me.[IDNo]

DoCmd.OpenReport "SingleTransaction", acViewPreview, ,
strWhere

End If

End Sub

Next Button:

Private Sub Command32_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.

Me.Dirty = False

End If

If Me.NewRecord Then 'Check there is a record to print

MsgBox "Select a record to print"

Else

strWhere = "[ID] = " & Me.[ID]

DoCmd.OpenReport "SingleInvoice", acViewPreview, , strWhere

End If

End Sub
 
Top