Form-Subform keep in sync with out Child/Master linked

J

John Keith

I wich to create a form/subform that has...
* Left half of the form showing a complete list of employee names and
positions (sortable via ordering on either name or positon field)
* Right half of the form showing the detail fields for the current row on
the left.
This combines a quick find and click style of locating a record to update in
one form.

I started by making the right-half a Singleform view to the details data.
Then making the left-half a sub-form linked (I tried making it a continuous
form, but linking the master/child fields forced only the one matching record
to show on the left.

By deleting the master/child link fields, The form looks right, but now I
need to enforce the two halves to stay synced-up.

Is there a way to use the record number(s) (that shows in the navigation
bars) to cause each to sync to the other as either the left or right half is
changed?
What is the property that represents this record number?
What is the event that fires when the record number is bumped (Im thinking
it would be "Current" for the left half, but for the continuous form too?)
 
J

John Keith

I found me.CurrentRecord that is available in the sub-form's Current event.
When I try to set the mainform's .CurrentRecord I get error:2135 This
property is read only.

Is there an alternative way to programattically change the record number?
If I manually type the matching record number into the navigation bar, the
detail changes...
 
K

Klatuu

This was an interesting problem. Here is how I solved it.
First, I used a third form as the main form. For the left side, I used a
datasheet form and for the right a single form. Then in the left subform I
put this in the current event:

Private Sub Form_Current()
With Me.Parent.form2.Form.RecordsetClone
.FindFirst "[ClientID] = " & Me.ClientID
If Not .NoMatch Then
Me.Parent.form2.Form.Bookmark = .Bookmark
End If
End With
End Sub
 
J

John Keith

thanks for the reply!

I discovered another method that works:
Private Sub Form_Current()
If SysCmd(acSysCmdGetObjectState, acForm, "CNPEmployee") <> 0 _
Then DoCmd.GoToRecord acDataForm, "CNPEmployee", acGoTo, Me.CurrentRecord
End Sub

The SysCmd check prevents an error when working on the sub-form with out
it's parent form open.

I am still working on the sort feature and the CurrentRecord property may
cause problems that your method will circumvent by using the recordset
object's bookmark to sync records.

--
Regards,
John


Klatuu said:
This was an interesting problem. Here is how I solved it.
First, I used a third form as the main form. For the left side, I used a
datasheet form and for the right a single form. Then in the left subform I
put this in the current event:

Private Sub Form_Current()
With Me.Parent.form2.Form.RecordsetClone
.FindFirst "[ClientID] = " & Me.ClientID
If Not .NoMatch Then
Me.Parent.form2.Form.Bookmark = .Bookmark
End If
End With
End Sub
 

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