Save New Record from Form

  • Follow


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.
-- 
Rick
0
Reply Utf 2/3/2010 8:34:09 PM

"rbeach" <rbeach@discussions.microsoft.com> wrote in message 
news:AF8D55CB-98D0-49FC-B740-4BE747A9AFD4@microsoft.com...
>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.

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Reply Dirk 2/3/2010 9:29:04 PM

Thanks for your assistance. Forcing the record to dirty worked.

-- 
Rick


"Dirk Goldgar" wrote:

> "rbeach" <rbeach@discussions.microsoft.com> wrote in message 
> news:AF8D55CB-98D0-49FC-B740-4BE747A9AFD4@microsoft.com...
> >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.
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Reply Utf 2/3/2010 10:09:02 PM

2 Replies
356 Views

(page loaded in 0.037 seconds)


Reply: