Check if current form record is new

  • Thread starter Thread starter McGeeky
  • Start date Start date
M

McGeeky

Hi. I have two forms; a menu form and a bound data form. One of the buttons
on the menu form navigates to the data form using DoCmd.RunCommand
acCmdRecordsGoToNew. This works fine. But, if I navigate away from the data
form and click the menu button again I get an error because the record on
the data form is still in progress.

Is there a way to either prevent navigating away from the data form if the
new record is incomplete, or, to first check if the new record is incomplete
and therefore not run the command DoCmd.RunCommand acCmdRecordsGoToNew?

Hope this makes sense and thanks in adavance!

McGeeky
 
McGeeky said:
Hi. I have two forms; a menu form and a bound data form. One of the
buttons on the menu form navigates to the data form using DoCmd.RunCommand
acCmdRecordsGoToNew. This works fine. But, if I navigate away from the
data form and click the menu button again I get an error because the
record on the data form is still in progress.

Is there a way to either prevent navigating away from the data form if the
new record is incomplete, or, to first check if the new record is
incomplete and therefore not run the command DoCmd.RunCommand
acCmdRecordsGoToNew?

Hope this makes sense and thanks in adavance!

McGeeky


The form's NewRecord property will be True if the form is currently
positioned at a new record.

If Me.NewRecord Then
'we're on the new record
Else
'we're not
End If

There's also a Dirty property that will be true if a record has unsaved
changes

If Me.Dirty Then
'we have unsaved changes
Else
'we don't
End If
 
Back
Top