Can't get sub to synch with Main

G

Guest

Sorry for the repost, but I'm getting desperate here. Pls help if you can.


My subform is not loading the correct data when I load patient data form a
search screen. When I initially open my main form by way of the search form
(switchboard>searchScreen>Main form with sub form) the correct data loads.
But on subsequent searches from the main form, the sub form still has the
prior patients data in it. My main and sub are related by the fldPINo in the
parent form and fldPINo in the sub form (the tables as well). Everything is
the way it is supposed to be (I believe.) So it make absolutetly no sense for
this to be happening. I have ME.Refresh in the fsub's OnCurrent event. I try
to requery the fsub's record source thru the main forms OnCurrent event using
Me.frmVisitNewEdit.Requery I'm absolutely baffled. On the sub form I have a
lstbox that displays all the visits of the loaded patient and it displays the
correct data, when I click on a record in the lst the corresponding data
loads into the sub form (because I have Me.Requery in the click event of the
lst.) So this makes me think I need to requery my sub forms data source. But
when a new patient is loaded into my main form, shouldn't the linked subform
also be loaded with that patients data?

This totally wierd. Any help would be greatly appreciated. Thanks, Rob
 
R

Rick Brandt

RobUCSD said:
Sorry for the repost, but I'm getting desperate here. Pls help if you can.


My subform is not loading the correct data when I load patient data form a
search screen. When I initially open my main form by way of the search form
(switchboard>searchScreen>Main form with sub form) the correct data loads.
But on subsequent searches from the main form, the sub form still has the
prior patients data in it. My main and sub are related by the fldPINo in the
parent form and fldPINo in the sub form (the tables as well). Everything is
the way it is supposed to be (I believe.) So it make absolutetly no sense for
this to be happening. I have ME.Refresh in the fsub's OnCurrent event. I try
to requery the fsub's record source thru the main forms OnCurrent event using
Me.frmVisitNewEdit.Requery I'm absolutely baffled. On the sub form I have a
lstbox that displays all the visits of the loaded patient and it displays the
correct data, when I click on a record in the lst the corresponding data
loads into the sub form (because I have Me.Requery in the click event of the
lst.) So this makes me think I need to requery my sub forms data source. But
when a new patient is loaded into my main form, shouldn't the linked subform
also be loaded with that patients data?

This totally wierd. Any help would be greatly appreciated. Thanks, Rob

This should have zero to do with the subform's RecordSource and you should not
need to refresh or requery the subform. This is entirely controlled by two
properties of the subform control, MasterLink and ChildLink. What do you have
entered in those properties?
 
G

Guest

fldPINo (qryPtDemographics) and fldPINo (qryVisit). I just discovered that
the forms initially load up synched, but on my sub from, frmVisits, I have a
lst box that has the following in the clk event;
Me.Filter = "VisitNo = " & Me.lstVisit.Value
Me.FilterOn = True

The lstBox displays the date and type of visits and the user clicks on this
to load the visit information into the form. When the forms (main & sub) are
loaded the main form, sub form, and lstBox are all synched correctly. It is
when the lstbox is clicked on, to view details of any of the visits, and then
a new patient is loaded after searching, that the prior patient's data is
still in the sub form. Only until the lstbox is click again is when the old
patient's data is cleared out and the correct info is loaded into the sub,
synched with the main form.

So I suspect that the lsBox filter needs to be cleared out when loading a
new pt. What do you think?

Thanks for helping on this Sunday am. Rob
 
T

Tom Lake

My subform is not loading the correct data when I load patient data form a
search screen. When I initially open my main form by way of the search
form
(switchboard>searchScreen>Main form with sub form) the correct data loads.
But on subsequent searches from the main form, the sub form still has the
prior patients data in it. My main and sub are related by the fldPINo in
the
parent form and fldPINo in the sub form (the tables as well). Everything
is
the way it is supposed to be (I believe.) So it make absolutetly no sense
for
this to be happening. I have ME.Refresh in the fsub's OnCurrent event. I
try
to requery the fsub's record source thru the main forms OnCurrent event
using
Me.frmVisitNewEdit.Requery I'm absolutely baffled. On the sub form I have
a
lstbox that displays all the visits of the loaded patient and it displays
the
correct data, when I click on a record in the lst the corresponding data
loads into the sub form (because I have Me.Requery in the click event of
the
lst.) So this makes me think I need to requery my sub forms data source.
But
when a new patient is loaded into my main form, shouldn't the linked
subform
also be loaded with that patients data?

This totally wierd. Any help would be greatly appreciated. Thanks, Rob

Not weird at all. The Master key must be the primary index in the table
used as the record source for the main form and the Child key must be an
index (but NOT the primary index) of the table used as the subform's record
source.

Tom Lake
 
G

Guest

That is the way it is set up. See post #3 of this thread, I think the problem
lies in the lstBox clk event. Tell me what you think. Thanks, rob
 
R

Rick Brandt

RobUCSD said:
fldPINo (qryPtDemographics) and fldPINo (qryVisit). I just discovered
that the forms initially load up synched, but on my sub from,
frmVisits, I have a lst box that has the following in the clk event;
Me.Filter = "VisitNo = " & Me.lstVisit.Value
Me.FilterOn = True

The lstBox displays the date and type of visits and the user clicks
on this to load the visit information into the form. When the forms
(main & sub) are loaded the main form, sub form, and lstBox are all
synched correctly. It is when the lstbox is clicked on, to view
details of any of the visits, and then a new patient is loaded after
searching, that the prior patient's data is still in the sub form.
Only until the lstbox is click again is when the old patient's data
is cleared out and the correct info is loaded into the sub, synched
with the main form.

So I suspect that the lsBox filter needs to be cleared out when
loading a new pt. What do you think?

Thanks for helping on this Sunday am. Rob

Sounds plausible. Try it and see what happens.
 
G

Guest

Rick, can you give me some guidance as to how I would clear the filter when a
new record is loaded? Thanks, Rob
 
R

Rick Brandt

RobUCSD said:
Rick, can you give me some guidance as to how I would clear the
filter when a new record is loaded? Thanks, Rob

In the current event of the main form...

Me.SubformControlName.Form.FilterOn = False
 
G

Guest

If it wasn't for you, I'd be screwed. What is your favorite charity so I can
make a donation. Thank you for everything Rich, you're an angel. Thank, Rob
 

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