showing records from subform in a mainform

G

Guest

I have a main form with a subforms. The subform is in a datasheet view. I
need to find a way when I moving my cursors on the record in the subform the
mainform show the data of the subform for the particular record ( in the form
view) .

Is there any way we can coding this at all.

Many thanks
 
G

Guest

I have a main form with a subforms. The subform is in a datasheet view. I
need to find a way when I moving my cursors on the record in the subform the
mainform show the data of the subform for the particular record ( in the form
view) .

Yes, it's possible by triggering the SubForms OnExit event and then settign
all the fields in the parent form to those in the subform (i.e. [fields1] =
Me![subfrm1]![fields1] etc.), and refreshing the Subform anytime you chanege
a value.
However, if you do not need to chnage the values in thesubform, I'd instead
suggest using a muti-column listbox, setting it's BoundColumn property to a
key and pulling up records in the main form via that key. That's way cleaner.

HTH

Chris
 
G

Guest

Hi There Chris,

I answered my own question which was the same as yours.
Set an on event Double Click and use an event procedure.

Private Sub [YourFieldinSubform]_DblClick(Cancel As Integer)
Dim JumpTo As String
JumpTo = Form_[YourSubFormName].[YourFieldinSubform]
On Error GoTo clickError
Forms![YourMainFormName]![YourFieldinMainForm].SetFocus
DoCmd.GoToRecord acActiveDataObject, , acFirst, no
DoCmd.FindRecord MapNo, acEntire, no, acSearchAll, no, acCurrent, no

clickError:
Resume Next

End Sub

Amend the bits above in Brackets only to your fileds and forms references.
This should in theory work for you too.

When you double click in a field in the subform (the childfield) it should
reference that as a string, set the focus to a field (The Parent) in the
mainform then go to the beginning of the recordset and then find it where the
Field and String are equal.

Thanks

Andi

Chris said:
I have a main form with a subforms. The subform is in a datasheet view. I
need to find a way when I moving my cursors on the record in the subform the
mainform show the data of the subform for the particular record ( in the form
view) .

Yes, it's possible by triggering the SubForms OnExit event and then settign
all the fields in the parent form to those in the subform (i.e. [fields1] =
Me![subfrm1]![fields1] etc.), and refreshing the Subform anytime you chanege
a value.
However, if you do not need to chnage the values in thesubform, I'd instead
suggest using a muti-column listbox, setting it's BoundColumn property to a
key and pulling up records in the main form via that key. That's way cleaner.

HTH

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top