subform selection to change detail record on mainform

  • Thread starter BBC via AccessMonster.com
  • Start date
B

BBC via AccessMonster.com

I have a mainform that displays detailed records for a particular selected
date (one at a time of course). I have a subform (datasheet view) that
displays all the records available (but not all the detail) for the
particular date. The table is bound to the mainform. The subform was
created with the Wizard and connects the same table to the maionform via the
"Date" field.

I want to be able to click on the subfrom record to be viewed and have the
main form then display that detail record. It would be OK to leave the focus
on the subform or switch the focus to the main form (or a control on it)
after the subform record is selected.
I currently am using the following code in the subform's "CURRENT" event to
change the primary key to that of the subfrom (thus switching to that record).

The following code in the subform's current event has been tried;

Private Sub Form_Current()
If Nz(Me.ID, 0) > 0 Then
Me.Parent.ID = Me.ID
Me.Parent.Requery
End If
End Sub

I get a "Can't assign a value to this object" on the Me.Parent.ID=Me.ID
line.
Me.ID has a correct value in it.

I've also tried
[forms]![mainformname]![ID]=Me.ID
Me.Parent!ID=Me.ID
... etc...

Any ideas why this isn't working or Is there another approach I should be
using for this?
thanks
 
R

ruralguy via AccessMonster.com

Here's some suggestions from MVP Allen Browne:
http://allenbrowne.com/ser-28.html
I have a mainform that displays detailed records for a particular selected
date (one at a time of course). I have a subform (datasheet view) that
displays all the records available (but not all the detail) for the
particular date. The table is bound to the mainform. The subform was
created with the Wizard and connects the same table to the maionform via the
"Date" field.

I want to be able to click on the subfrom record to be viewed and have the
main form then display that detail record. It would be OK to leave the focus
on the subform or switch the focus to the main form (or a control on it)
after the subform record is selected.
I currently am using the following code in the subform's "CURRENT" event to
change the primary key to that of the subfrom (thus switching to that record).

The following code in the subform's current event has been tried;

Private Sub Form_Current()
If Nz(Me.ID, 0) > 0 Then
Me.Parent.ID = Me.ID
Me.Parent.Requery
End If
End Sub

I get a "Can't assign a value to this object" on the Me.Parent.ID=Me.ID
line.
Me.ID has a correct value in it.

I've also tried
[forms]![mainformname]![ID]=Me.ID
Me.Parent!ID=Me.ID
... etc...

Any ideas why this isn't working or Is there another approach I should be
using for this?
thanks
 
B

BBC via AccessMonster.com

This is an incredible site and I got lots of great info from it. Thanks

Unfortunately the example does not actually seem to apply.

My form & subfrom both have the same (already filtered) recordsource (subform
is a list of the filtered records the mainform is expanded detail of one
selected record from the list). I just want a selection (click on it) of a
record on the subform to cause the mainform to move to/display that record.
Basically keeping the mainform in sync with the selected record on the
subform.

**********************************************
ruralguy said:
Here's some suggestions from MVP Allen Browne:
http://allenbrowne.com/ser-28.html
I have a mainform that displays detailed records for a particular selected
date (one at a time of course). I have a subform (datasheet view) that
[quoted text clipped - 31 lines]
using for this?
thanks
 

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