Migrating data across forms

StephenB

Registered User.
Local time
Yesterday, 23:03
Joined
Apr 18, 2002
Messages
101
1. I use the following to enter comments into a field and have it feed over to a locked field. User's enter comments in the response field, the comments feed over to the history field where it's stored and displayed in chronological order. The comments in the response field are then deleted.

Private Sub Response_AfterUpdate()
Response = Response.Text
History = Now() & ": " & Response.Text & " " & [Submitter] & Chr(13) & Chr(10) & History
Response = " "
End Sub

This is working fine for me on the same form. However, I need it to migrate onto another form as well. Any suggestions?

2. Along the same line, I have table A and Table B as well as form A and form B. Table A is prepopulated (this table is linked) while table B is blank. I want to place a command button on form A that will open form B and populate a like field that will be stored in table B. On form A I have field [authorizations]. I will open form B and I want the [authorizations] field on form B populated with the number from form A.

I set the default on the form B.authorization to:
=[form]![form A]![authorizations]

However, the data doesn't feed down to table B and doesn't create a new record in table B. [Authorizations] on table B will be the primary key, so I only need it to create a new record if the authorization number doesn't already exist on table B. Otherwise, I want it to display the record with the authorization number displayed on form A.

Help on either of these?
 
1. The history is obviously a stored field. Why cant you bind the control on the other form to the history field to display the contents?. If the other form is already open, you can refresh the data by modifying your code to

Private Sub Response_AfterUpdate()
Response = Response.Text
History = Now() & ": " & Response.Text & " " & [Submitter] & Chr(13) & Chr(10) & History
Response = " "
Forms!NameOfOtherForm.Refresh 'This form MUST be open otherwise you will get an error.
End Sub

2. Look at the demo I sent you on using a combo box and using the Not In List property to open a new form at a new record to enter new data. To enter the new data onto the New form, replace the openform line with this line
DoCmd.OpenForm "NameOfFormToOpen", acNormal, , , acFormAdd, acDialog, NewData

and on the form you are opening to add a new record on the form load, use
Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.NameOfAuthorisationControl = Me.OpenArgs 'Make sure you use the name of the control, not the field!
End If
End Sub

HTH.
 

Users who are viewing this thread

Back
Top Bottom