dbTalk Databases Forums  

Changing SubForm Recordsource

comp.databases.ms-access comp.databases.ms-access


Discuss Changing SubForm Recordsource in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Darlington
 
Posts: n/a

Default Changing SubForm Recordsource - 05-13-2011 , 03:15 AM






I'm using Access 2010 and trying to change the recordsource of a subform by
pressing a button on the parent form which contains the following code:

With Me!sfPeakTypes
.LinkMasterFields = ""
.LinkChildFields = ""
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
End With

The correct results flash on the screen in the subform, but then clear,
leaving a blank subform.
Any ideas out there?

--
Bob Darlington
Brisbane

Reply With Quote
  #2  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Changing SubForm Recordsource - 05-13-2011 , 02:51 PM






Bob Darlington wrote:

Quote:
I'm using Access 2010 and trying to change the recordsource of a subform by
pressing a button on the parent form which contains the following code:

With Me!sfPeakTypes
.LinkMasterFields = ""
.LinkChildFields = ""
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
End With

The correct results flash on the screen in the subform, but then clear,
leaving a blank subform.

Shooting in the dark, but ... Right after the subform goes
blank, use the Immediate Window to check the
LinkMaster/Child properties to see if they were set to an
auto link field:
?Forms!yourform.subformcontrol.LinkMasterFields
?Forms!yourform.subformcontrol.LinkChildFields
If those come back blank, forget I posted this.

But if those display some field name, then try to find the
equivalent of the A2003 Tools - Options - Tables/Queries -
AutoIndex On Import/Create and clear it.

--
Marsh

Reply With Quote
  #3  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Changing SubForm Recordsource - 05-13-2011 , 06:00 PM



"Marshall Barton" <marshbarton (AT) wowway (DOT) com> wrote

Quote:
Bob Darlington wrote:

I'm using Access 2010 and trying to change the recordsource of a subform
by
pressing a button on the parent form which contains the following code:

With Me!sfPeakTypes
.LinkMasterFields = ""
.LinkChildFields = ""
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
End With

The correct results flash on the screen in the subform, but then clear,
leaving a blank subform.


Shooting in the dark, but ... Right after the subform goes
blank, use the Immediate Window to check the
LinkMaster/Child properties to see if they were set to an
auto link field:
?Forms!yourform.subformcontrol.LinkMasterFields
?Forms!yourform.subformcontrol.LinkChildFields
If those come back blank, forget I posted this.

But if those display some field name, then try to find the
equivalent of the A2003 Tools - Options - Tables/Queries -
AutoIndex On Import/Create and clear it.

--
Marsh
Thanks Marsh.
That was the problem, but clearing the auto index didn't work.
But you put me on the right track. I put the Link lines after (instead of
before) resetting the recordsource and it now works fine.

With Me!sfPeakTypes
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
.LinkMasterFields = ""
.LinkChildFields = ""
End With

Thanks again.
--
Bob Darlington
Brisbane

Reply With Quote
  #4  
Old   
Marshall Barton
 
Posts: n/a

Default Re: Changing SubForm Recordsource - 05-13-2011 , 10:36 PM



Bob Darlington wrote:
Quote:
"Marshall Barton" wrote
Bob Darlington wrote:

I'm using Access 2010 and trying to change the recordsource of a subform
by pressing a button on the parent form which contains the following code:

With Me!sfPeakTypes
.LinkMasterFields = ""
.LinkChildFields = ""
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
End With

The correct results flash on the screen in the subform, but then clear,
leaving a blank subform.


Shooting in the dark, but ... Right after the subform goes
blank, use the Immediate Window to check the
LinkMaster/Child properties to see if they were set to an
auto link field:
?Forms!yourform.subformcontrol.LinkMasterFields
?Forms!yourform.subformcontrol.LinkChildFields
If those come back blank, forget I posted this.

But if those display some field name, then try to find the
equivalent of the A2003 Tools - Options - Tables/Queries -
AutoIndex On Import/Create and clear it.


That was the problem, but clearing the auto index didn't work.
But you put me on the right track. I put the Link lines after (instead of
before) resetting the recordsource and it now works fine.

With Me!sfPeakTypes
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
.LinkMasterFields = ""
.LinkChildFields = ""
End With

Did you close and reopen Access after clearing the AutoIndex
option? I haven't seen this issue in years since I made it
a habit for all new databases so I'm pretty sure it should
work.

I think it's a good idea regardless of your current problem,
if for no other reason than having a field indexed just
because its name matches up with something in that list.

--
Marsh

Reply With Quote
  #5  
Old   
Bob Darlington
 
Posts: n/a

Default Re: Changing SubForm Recordsource - 05-14-2011 , 11:51 PM



"Marshall Barton" <marshbarton (AT) wowway (DOT) com> wrote

Quote:
Bob Darlington wrote:
"Marshall Barton" wrote
Bob Darlington wrote:

I'm using Access 2010 and trying to change the recordsource of a subform
by pressing a button on the parent form which contains the following
code:

With Me!sfPeakTypes
.LinkMasterFields = ""
.LinkChildFields = ""
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
End With

The correct results flash on the screen in the subform, but then clear,
leaving a blank subform.


Shooting in the dark, but ... Right after the subform goes
blank, use the Immediate Window to check the
LinkMaster/Child properties to see if they were set to an
auto link field:
?Forms!yourform.subformcontrol.LinkMasterFields
?Forms!yourform.subformcontrol.LinkChildFields
If those come back blank, forget I posted this.

But if those display some field name, then try to find the
equivalent of the A2003 Tools - Options - Tables/Queries -
AutoIndex On Import/Create and clear it.


That was the problem, but clearing the auto index didn't work.
But you put me on the right track. I put the Link lines after (instead of
before) resetting the recordsource and it now works fine.

With Me!sfPeakTypes
.Form.RecordSource = "SELECT * FROM txPeakTypes WHERE PropNum = 98"
.LinkMasterFields = ""
.LinkChildFields = ""
End With


Did you close and reopen Access after clearing the AutoIndex
option? I haven't seen this issue in years since I made it
a habit for all new databases so I'm pretty sure it should
work.

I think it's a good idea regardless of your current problem,
if for no other reason than having a field indexed just
because its name matches up with something in that list.

--
Marsh
Marsh,
No. I closed the application but not Access.
But as you suggested, I've cleared the AutoIndex now and all seems well.


--
Bob Darlington
Brisbane

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.