Check if current form record is new

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
 
B

Brendan Reynolds

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
 

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