Close Form Bug

  • Thread starter Thread starter bigturnip
  • Start date Start date
B

bigturnip

I have a form which when I close using the close butto
returns the following error:
YOU CAN'T SAVE THIS RECORD AT THIS TIM

JWork may have encountered an error while trying to save a record.
If you close this object now, the data changes you made will be lost
Do you want to close the database object anyway?

[YES] [NO]

However a simple button with the code -docmd.close- does the trick.
would like to keep the close button. I have tried restarting and mad
sure all the network connections are ok incase there was a proble
there but all checks out okay. I have also tried copying all object
and code to a new form with no success.

If you say yes to the message all changes are saved. If you say no t
the message the close button then becomes inactive (you can still clic
it but it does nothing)

The only possible code that can run on close is the after update even
which has two lines of code:

Me.Modify = DLookup("FirstName", "tbl_USERS", "ID = "
Me.txt_USERNAME) & " " & DLookup("Surname", "tbl_USERS", "ID = "
Me.txt_USERNAME)
Me.ModifyDate = Now()

I am using Access 2002 on Windows XP
Any help would be much appreciated.
[/COLOR
 
bigturnip said:
I have a form which when I close using the close button
returns the following error:
YOU CAN'T SAVE THIS RECORD AT THIS TIME

JWork may have encountered an error while trying to save a record.
If you close this object now, the data changes you made will be lost.
Do you want to close the database object anyway?

[YES] [NO]

However a simple button with the code -docmd.close- does the trick. I
would like to keep the close button. I have tried restarting and made
sure all the network connections are ok incase there was a problem
there but all checks out okay. I have also tried copying all objects
and code to a new form with no success.

If you say yes to the message all changes are saved. If you say no to
the message the close button then becomes inactive (you can still
click
it but it does nothing)

The only possible code that can run on close is the after update event
which has two lines of code:

Me.Modify = DLookup("FirstName", "tbl_USERS", "ID = " &
Me.txt_USERNAME) & " " & DLookup("Surname", "tbl_USERS", "ID = " &
Me.txt_USERNAME)
Me.ModifyDate = Now()

I am using Access 2002 on Windows XP
Any help would be much appreciated.

You have the above code in the form's AfterUpdate event? That would be
a mistake, as the code would then be dirtying the form again immediately
after saving the record. Put that code in the form's BeforeUpdate
event.
 
Back
Top