Saving variables and not entering record until final confirmation

  • Thread starter Thread starter Wayne Morgan
  • Start date Start date
W

Wayne Morgan

If the variables are declared at the form level (in the Declarations section
of the form's code module) they should be available to all procedures on the
form until the form is closed.

That said, there may be an easier way. Let the user make the entries
directly into the form's controls and use the BeforeUpdate event of the form
to verify the values that have been entered. You could create a pop-up form
to display the entries if you wanted something more complicated than just a
message box. If so, open the form with the acDialog window mode argument in
the DoCmd.OpenForm call. Have two buttons on the form that will set a value
in a hidden textbox on the original form. When you close the form, the
BeforeUpdate code will continue to run. Check the value that was set in the
hidden textbox and react accordingly. To abort the save, set Cancel = True.
 
I have been trying to use VBA to maintain the values of several variables
until it is actually time to confirm them, and THEN make the record.

For instance, a user will enter data and choose values via msgbox prompts
and drop-down lists on a form (ie. the date, then choosing a name, then
choosing a task type, then entering how much time it took, etc.). At then
end of the choices and inputs, I'd like to call up a form or msgbox or
something that shows all the choices and data, w/ some sort of ("OK?" and
"no, re-enter" prompt). If they choose OK, I'd like to have the record
created and the fields filled in w/ the data chosen and entered thus far.

The problems I have are:

- I don't know how to code the prcedure that enters a new record w/ all the
variables
- I keep running into variable values being lost or dropped as I proceed
down the choices.

I am flexible on whether I use msgbox prompts, form fields, etc. on
collecting the data, whichever makes it easier. May main goal here is to
collect up to 10 variable values, and then enter them in a new record (or do
not create a new record at all, or create the record from the beginning, but
delete the record if the user chooses "not OK," etc.).

Thanks for any help, y'all. If you happen to know the VBA necessary, I'd
really appreciate a sample, like assuming 4 data fields named "field1,"
"field2," etc.

R

PS: Using Access 2000
PPS: If this is the wrong group for this, please point me in the right
direction, I'd appreciate it.
 
Back
Top