Error on command button

  • Thread starter Thread starter Serendipity
  • Start date Start date
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
 
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.
 
Back
Top