Hank said:
I have several forms open and have a click event on one form. It should
populate a field with a number but doesn't. I am lost !!! Code Follows:
Private Sub CustOrderNum_Click()
Me.CustOrderNum.Value = Forms![AirWayBill]![AirWayBillNo]
DoCmd.Close acForm, Me.Name, acSaveYes
End Sub
Are any error messages displayed?
Are you clicking on CustOrderNum? This code will do nothing unless you do.
Is the form "AirWayBill" open when you click on CustOrderNum? If it isn't,
I'd expect an error to be raised.
Does the control AirWayBillNo on form AirwayBill contain a value at the
moment when you click on CustOrderNum (on the current form)? If not, you'll
just be assigning Null to CustOrderNum.
Since your code closes the form immediately after the value is assigned to
CustOrderNum, how do you know it isn't working? You might try temporarily
commenting out the "DoCmd.Close" line, just to see what happens when you
click CustOrderNum.
As Paul Shapiro has pointed out, you probably don't want to be specifying
acSaveYes when you close the form, because that saves changes to the
*design* of the form. However, just closing the form if its record has been
modified should force the record to be saved, unless there is some reason
why it can't be.
If CustOrderNum *is* being assigned a number, but it isn't being saved when
you close the form, I wonder if perhaps that control is not bound to a
field. What is the ControlSource of CustOrderNum?