Main form with two subforms

G

Guest

Hi,

I have a main form (which contains Box Number Details) and a sub form # 1
that has the contents of each box (each form is connected to a separate table
but joined by a primary and foreign key) - this works fine.

Now what I would like to achieve is to have another sub form # 2 underneath
which displays all of the Box details (in datasheet view), so when a record
is clicked on this form, it is reflected on both the main form and sub form #
1.

In essence the second sub form is just a summary of all the data in the main
form, but allows the user to see / edit details all in one screen.

Any advice would be greatly appreciated...

Cheers,
GLT.
 
A

Arvin Meyer [MVP]

There are several ways to do this. Probably the easiest is very well
illustrated and documented in the Orders forms and subforms in the Northwind
sample database that came with Access and should be a part of the default
install. Click on Help >>> Sample databases to get to it.
 
G

Guest

I have added the following code to my sub form # 2 'on-click' property:

Private Sub Form_Click()

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Me!ID
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Forms!frm_TAPMAN_MedLogReg![Date].SetFocus

End Sub


The focus goes back to the main form OK, but I cannot get the mainform to
change to the record that was selected in the sub form # 2.

Any help would be appreciated.

Thanks,
GLT.
 
G

Guest

For anyone else trying to acheive selecting a record on a subform which is
then reflected in the mainform (there are lots), then pasting this code in
the 'on click' property works perfectly:

Parent.RecordsetClone.FindFirst "ID= " & Me.ID
If Not Parent.RecordsetClone.EOF Then
Parent.Bookmark = Parent.RecordsetClone.Bookmark
End If

Thanks to Bob Quintal for this (found it in one of the other posts) ...

Cheers.
GLT.
 

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