Save Record

Kila

Registered User.
Local time
Today, 17:30
Joined
Mar 5, 2003
Messages
275
I have a form that has a button on it that opens another form (survey) that pulls information off the parent form, including an autonum ID number. The survey cannot "grab" the autonum until the record has been saved. So if I create a new record on the parent form and hit the button that opens the survey, it will not "find" the ID number. If I go to another record on the parent form and return, thus SAVING the record, it works just fine. How can I force it to save the record when I click the button that opens the survey? I tried

Docmd.Save

in the button's "on click" event, but that does not seem to help. Can anyone assist? I'm sure this is something very simple. Thanks.
 
Try

DoCmd.RunCommand acCmdSaveRecord
 
I have a form that has a button on it that opens another form (survey) that pulls information off the parent form, including an autonum ID number. The survey cannot "grab" the autonum until the record has been saved. So if I create a new record on the parent form and hit the button that opens the survey, it will not "find" the ID number. If I go to another record on the parent form and return, thus SAVING the record, it works just fine. How can I force it to save the record when I click the button that opens the survey? I tried

Docmd.Save

in the button's "on click" event, but that does not seem to help. Can anyone assist? I'm sure this is something very simple. Thanks.


DoCmd.RunCommand acCmdSaveRecord
 
You have to use the docmd.runcommand ..... but I not exactly sure what command it is. I believe intellsense should help out once you enter the above.
 
Fastest fingers in the west! :D
 
Thanks! One more...

Thanks Fast Fingers...and everyone else! That worked. Here is one more that SHOULD be a quickie.

Same form...
THere is a field that calculates patient age. The Survey has a field on it that I want to "grab" the age that has been calculated in the field on the parent form...txtAge. I have tried to put this in the code:

Me.txtPatientAge.DefaultValue = [Forms]![frmTraineeInfo]![txtAge]

...but I suspect that it is trying to capture the calculation, not the resulting number, b/c I get #Name. I need the NUMBER at the time to calculate demographics on the survey data based on the ages at the time the survey was done. Any thoughts?

Thanks so much!
 
Is the form still open when the report is open? It seems like the report can't find the form and/or control you are referrencing in your expression.
 
I'm not sure if that is the problem...

Thanks for your response...

I have not even GOTTEN to the report yet. THe Survey is a form with a field on it that is supposed to grab that number and save it in the table. THere is another reference in the same code that works...

Me.txtActionID.DefaultValue = [Forms]![frmTraineeInfo]![sfrActions]![txtActionID]

THis is the one that would not work until the record was saved.

Also, one field in the survey has this in the properties as the default....

=([Forms]![frmTraineeInfo]![txtLastName]) & ", " & ([Forms]![frmTraineeInfo]![txtFirstName]) & " (" & Right([Forms]![frmTraineeInfo]![txtSSN],4) & ")"

It works just fine, referencing a field on the same form as txtAge (next to it in fact), but when I tried to do something similar in txtPatientAge:

=([Forms]![frmTraineeInfo]![txtAge])
or
=[Forms]![frmTraineeInfo]![txtAge]

I got the #Name error.
 

Users who are viewing this thread

Back
Top Bottom