Save New Record from Form

R

rbeach

I have a form that opens with information already in filled into all of the
text boxes. The information is either from another form or defaulted into the
text boxes.

Example: The "AcctNum" is from the "NewAcct" Form. The "ReqDate" is default
"Date()". The "Status" Field is defaulted as "UnderReview".

This information only needs to be reviewed and then the form closed. With
this in mind all textboxes are locked.

When the form is closed, I want a new record saved in the table that the
form references which would be "AccountStatus".

Problem: If the date is entered manually I can create the record. With all
the textboxes locked I cannot do this. I have tried the "On Close"
acCmdSaveRecord but it does not create the record in the table. I do not
recieve any errors, but the record does not exist.
 
D

Dirk Goldgar

rbeach said:
I have a form that opens with information already in filled into all of the
text boxes. The information is either from another form or defaulted into
the
text boxes.

Example: The "AcctNum" is from the "NewAcct" Form. The "ReqDate" is
default
"Date()". The "Status" Field is defaulted as "UnderReview".

This information only needs to be reviewed and then the form closed. With
this in mind all textboxes are locked.

When the form is closed, I want a new record saved in the table that the
form references which would be "AccountStatus".

Problem: If the date is entered manually I can create the record. With all
the textboxes locked I cannot do this. I have tried the "On Close"
acCmdSaveRecord but it does not create the record in the table. I do not
recieve any errors, but the record does not exist.


How does the AcctNum get the value from the NewAcct form? Is it picked up
by a default value expression? If it were assigned by code, the record
would be dirty and the simple act of closing the form ought to save the
record automatically. If the record isn't dirty, you can force it to become
dirty by assigning one of the controls' values to itself; e.g.,

Me.AcctNum = Me.AcctNum

The Close event is too late for this, though, as by that point the form has
already been unloaded. You could use the Unload event, I think.

Are you sure that the user is never going to have any choice about whether
the record is saved or not? If you code the Unload event to always save the
record, they're going to be stuck with that record, come hell or high water.
And if you're going to do that, you might as well create the record in the
table via an append query befor ever opening the form, and then just open
the form to display the record you already created.
 

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