check if their is a new entry

amoona

Registered User.
Local time
Today, 21:02
Joined
Jan 18, 2005
Messages
20
Hi..

I have a form with a subform where the user has to enter some data in them. when the user moves to the subform the data in the form automatically get saved in the table(you all know that i suppose).
In the form i have a back button where the user is able to go back to the main form.the code of the button is:

Code:
 If MsgBox("Do you want to save before exit?", vbYesNo, "Save") = vbYes Then
        DoCmd.RunCommand acCmdSave
        MsgBox ("Data has been saved.")
        DoCmd.Close
        DoCmd.OpenForm "Main"
      Else
        DoCmd.RunCommand acCmdDeleteRecord
        DoCmd.Close
        DoCmd.OpenForm "Main"
      End If
    Else
       DoCmd.Close
       DoCmd.OpenForm "Main"
    End If

my problem is when the user hasn't entered any data and wants to return i would get an error (because i'm trying to delete a record which doesn't exist
) how can i check if a record has been eneterd.
if new entry then
deleterecord,close,open mainform
else
close,open main form
endif

thankxx in advance..
hope my grammer is correct
 
Try testing for new record
Code:
if me.newrecord then
    me.undo
else
    ' perform the delete
end if
 
thanxxx for all ur help :)
 

Users who are viewing this thread

Back
Top Bottom