Folks,
1.
DoCmd.Save saves the OBJECT you specify in the argument list, but not the current record.
To save the current record in a bound form use:
DoCmd****nCommand acCmdSaveRecord
2.
To pass a value from a form to an other form, I strongly recommend using the OpenArgs optional argument of the OpenForm method.
In this argument you can pass any value to an opening form.
To pass a value to an opening form use the following:
'---------------
DoCmd.OpenForm "ChildForm",,,,,,Var
'---------------
where "ChildForm" is the opening form's name, and "Var" is the variable holding the value to be passed. The OpenArgs argument is the 7th parameter of the OpenForm method. To avoid run-time errors, make sure that the appropriate number of commas are present in the method's parameter list.
Then, include a line into the OnOpen event handler of the opening form to retrieve the value passed in the OpenArgs argument.
If you wish to put this value to the txtValue field, for example, type this:
'---------------
txtValue=OpenArgs
'---------------
Generally, using public or global variables in a project can be dangerous, and can make debugging more difficult.
I would recommend to reduce the number of these kind of variables as low as possible.
Furthermore, if an unhandled run-time error occurs, then variables often lose their values, and this can cause additional run-time errors in the application.
Another advantage of using OpenArgs is that When an unhandled run-time error occurs, the OpenArgs property does NOT lose its value. It's kept as long as the form is loaded.
BRegs,
TBÁrpi