form problem

bigmac

Registered User.
Local time
Today, 06:30
Joined
Oct 5, 2008
Messages
302
hi all, can you help please, I have a main form and a datasheet form , what I want to do is if I start a new record on the datasheet then a field on the new record [name] will auto update with the same value as on the main form from a text box called [name] how do I go about this please, if you can show me I would appreciate this very much.:confused:
 
You should really enter data in the form, then you can run an append query to add the records as much as you need.
Append query.
 
I work a lot with datasheet as subform in a mainform.
The subform shows the records and the main form shows all the information of the selected record in the datasheet

In the oncurrent event of the datasheet I copy all the information from the active record to the main form with vba code like
Me.Parent!yourfieldname = Me.yourfieldname
In this case the names of the fields are identical in both sub and main form.

That makes the next step easy: to copy updates from the main form to the active record in the subform- This is done in the afterupdate event of the field in the mainform


Private Sub yourfield_AfterUpdate()
UpdateChildformfield (Me.ActiveControl.NAME)
End Sub

Private Function UpdateChildformfield(fieldname As String)
Me.yourdatasheetname.Form(fieldname) = Me(fieldname)
End Function


Hope this is a little in the direction you are referring to.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom