Error on command button

S

Serendipity

I have a form that I am using to limit the criteria for a report that shows
all of the inspections to date for multiple sites. It has a combo box that
lists the the criteria to select. It is 4 columns, the first being the
primary key(InspectionReportID) and hidden from the end user. Upon selection
of the inspection you would like to preview, I then have a command button to
preview the report before printing. I was successful with this code on
another form that was the data entry form for entering the information into
the database and works great! I just changed the cmd button name to the
newest. When I run it i get the error Run-time error "2455": you entered an
expression that has an invalid reference to the property dirty.
Code is:


Private Sub cmdPreviewInspectionReport_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 = "[InspectionReportID] = " & Me.[InspectionReportID]
DoCmd.OpenReport " rptRoofInspectionReportCurrentlySelected ",
acViewPreview, , strWhere
End If
End Sub
 
G

ghetto_banjo

is your form bounded? I know dirty doesnt work on unbound forms,
don't see any other reason why that error message would come up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top