save onexit or onchange

mkelly

Registered User.
Local time
Today, 13:09
Joined
Apr 10, 2002
Messages
213
I have inherited a database and am endining up with duplicate record numbers since the record numbers are entered by the user even though there is a subform that shows them the record number.

I changed the control source on the mail form to "[Box Number Register Form].[Form]![BoxNumber]" this way when they enter data in the sub form it will populate the box number field on the mail form.

My problem is I do not know the command onexit or onchange to save this value to the table "[FILE STORAGE DATABASE]![BOXNUMBER]"

All help appriciated....
 
You can do,

On Unload = Save On Exit

On Dirty = Save On Change

But really in order for this to work right, you would need to have an Append Query, and then on exit Append that data to the table. Or have a save button and tell that to run the append query if all the fields are filled out correctly.
 
Thanks but I still do not nuderstand how I would code that in the expression?? :confused:
 
1.) You must first create a table to hold your data before it gets appended to the real table. just copy the real table and rename it something like tblAppNameofRealtable.

2.) Create an append query, Query Design View, add your tblappNameofRealtable table, then click Add then close. then Drag the * from the table to the rows at the bottom. Right click in the Gray area select Query Type>Append Query... This will bring up a box to ask you where the values should be appended to. select the Realtable.

If you already know how to get to form properties go to 3...

2.) In the Properties menu of the Form, you can double click in the upper left area of the form in the box between the upper ruler and the left ruler.
3.) Go to events tab. To save on Exit, scroll down to On Unload.
click the ... and choose expression builder.

type:

DoCmd.OpenQuery ("Name of Append Query")

If you dont like the Access warnings surround the Open Query with these

DoCmd.SetWarnings (False)
DoCmd.OpenQuery ("Name of Append Query")
DoCmd.SetWarnings (True)


And thats how you do that, if you want to make a save button just add that code to the OnClick event.

Peace! :D
 

Users who are viewing this thread

Back
Top Bottom