473,416 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Main Form & Continuous Subform (with Requery) Problem

Hi,

I have two very similar forms each with a subform. The main form gets
a few fields from the user and passes this back to a query that the
subform is bound to. The requery is done when the user enters the
last qualifying field on the main form.

In one case this works fine, the subform shows the data the user wants
to update -- which means showing all the data put in previously (ie
showing this via the requery and the continuous option on the subform)
and standing by for input. In the other case, the requery refuses to
display in the continuous subform showing one blank record (really a
partial record). With the parent form filled in, I can manually
trigger the query and see it has the correct records.

Does anyone know of some obscure setting or restriction that I need to
tweak to get the blasted thing to work?

Thanks,

Dave
Nov 13 '05 #1
4 6953
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainForm!SomeTextbox
and the problem is that this does not always load/stay up to date correctly.

Would it be possible to use the LinkMasterFields/LinkChildFields properties
of the subform instead? That should make life simpler if it is possible, and
it works for most things unless you are choosing a range rather a discreet
value (e.g. from start date to end date), or trying to get all values when
some of the controls in the linkage may be null.

Another alternative is to reassign the RecordSource of the subform in the
Current event of the main form. By creating a SQL string that concatenates
any literal values into the string, you can handle ranges, ignore nulls, and
get the exact result you want. You may need to check that Access does not
become overhelpful and decide to assign values to the
LinkMasterFields/LinkChildFields based on the new RecordSource. And you also
have to be careful to avoid cyclic dependencies, such as something in the
main form that is dependent on something in the subform. Conditional
formatting can also trigger this.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave Boyd" <da**********@boeing.com> wrote in message
news:e7*************************@posting.google.co m...

I have two very similar forms each with a subform. The main form gets
a few fields from the user and passes this back to a query that the
subform is bound to. The requery is done when the user enters the
last qualifying field on the main form.

In one case this works fine, the subform shows the data the user wants
to update -- which means showing all the data put in previously (ie
showing this via the requery and the continuous option on the subform)
and standing by for input. In the other case, the requery refuses to
display in the continuous subform showing one blank record (really a
partial record). With the parent form filled in, I can manually
trigger the query and see it has the correct records.

Does anyone know of some obscure setting or restriction that I need to
tweak to get the blasted thing to work?

Thanks,

Dave

Nov 13 '05 #2
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41**********************@per-qv1-newsreader-01.iinet.net.au>...
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainForm!SomeTextbox
and the problem is that this does not always load/stay up to date correctly.

Would it be possible to use the LinkMasterFields/LinkChildFields properties
of the subform instead? That should make life simpler if it is possible, and
it works for most things unless you are choosing a range rather a discreet
value (e.g. from start date to end date), or trying to get all values when
some of the controls in the linkage may be null.

Another alternative is to reassign the RecordSource of the subform in the
Current event of the main form. By creating a SQL string that concatenates
any literal values into the string, you can handle ranges, ignore nulls, and
get the exact result you want. You may need to check that Access does not
become overhelpful and decide to assign values to the
LinkMasterFields/LinkChildFields based on the new RecordSource. And you also
have to be careful to avoid cyclic dependencies, such as something in the
main form that is dependent on something in the subform. Conditional
formatting can also trigger this.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave Boyd" <da**********@boeing.com> wrote in message
news:e7*************************@posting.google.co m...

I have two very similar forms each with a subform. The main form gets
a few fields from the user and passes this back to a query that the
subform is bound to. The requery is done when the user enters the
last qualifying field on the main form.

In one case this works fine, the subform shows the data the user wants
to update -- which means showing all the data put in previously (ie
showing this via the requery and the continuous option on the subform)
and standing by for input. In the other case, the requery refuses to
display in the continuous subform showing one blank record (really a
partial record). With the parent form filled in, I can manually
trigger the query and see it has the correct records.

Does anyone know of some obscure setting or restriction that I need to
tweak to get the blasted thing to work?

Thanks,

Dave


Allen,

Yes, you are correct and I believe the criteria you mention would
allow me to use form/subform linked fields, but it's not obvious what
I should do. (I'm guessing the original form (that works) was
generated by an Access wizard -- possibly the former database
architect, but not likely -- and I'm trying to manually duplicate that
as an inexperienced form builder.)

On the main form I have a set of master fields. I want the subform to
display the subset of records equivalent to the select query where the
two fixed master fields are chosen by the user on the main form.

How would the linked fields approach be setup? I tried to eliminate
the query by linking both forms to the table and then linking the two
fields in the main form to the subform. The two fields don't actually
appear in the subform. There are actually row source queries on combo
boxes for some of the subform fields since they do double duty as
display slots for existing records and entry of new data for the next
user defined record. According to what I understand, when I enter the
linked master fields the form should display all related records?
This doesn't seem to work so I've still got some screwed up somewhere.

Dave
Nov 13 '05 #3
Hi Dave

I'm not really clear here - esp. about the combos in the subform. If you are
trying to use the non-bound column of the combo in the LinkChildFields of
the subform control, it might be better to a use a query as the RecordSource
of the subform, and include the combo's table so that the field you need to
link on is in the RecordSource.

If you need an example of how subforms work, open the Northwind sample
database, and look at the Customer Orders form. The first subform - Customer
Orders Subform1 - has CustomerID in both the LinkMasterFields and
LinkChildFields, so the subform shows the records matching the CustomerID in
the main form. The 2nd subform - Customer Orders Subform2 has its
LinkChildFields set to OrderID, and its LinkMasterFields set to
[Customer Orders Subform1].Form![OrderID]
That means that its records will match the OrderID in the other subform.

Hopefully that example demonstrates what needs to go into the
LinkChildFields/LinkMasterFields in your example. If you can get the fields
into the source query, it is simplest and most stable.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave Boyd" <da**********@boeing.com> wrote in message
news:e7*************************@posting.google.co m...
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainForm!SomeTextbox
and the problem is that this does not always load/stay up to date
correctly.

Would it be possible to use the LinkMasterFields/LinkChildFields
properties
of the subform instead? That should make life simpler if it is possible,
and
it works for most things unless you are choosing a range rather a
discreet
value (e.g. from start date to end date), or trying to get all values
when
some of the controls in the linkage may be null.

Another alternative is to reassign the RecordSource of the subform in the
Current event of the main form. By creating a SQL string that
concatenates
any literal values into the string, you can handle ranges, ignore nulls,
and
get the exact result you want. You may need to check that Access does not
become overhelpful and decide to assign values to the
LinkMasterFields/LinkChildFields based on the new RecordSource. And you
also
have to be careful to avoid cyclic dependencies, such as something in the
main form that is dependent on something in the subform. Conditional
formatting can also trigger this.
"Dave Boyd" <da**********@boeing.com> wrote in message
news:e7*************************@posting.google.co m...
>
> I have two very similar forms each with a subform. The main form gets
> a few fields from the user and passes this back to a query that the
> subform is bound to. The requery is done when the user enters the
> last qualifying field on the main form.
>
> In one case this works fine, the subform shows the data the user wants
> to update -- which means showing all the data put in previously (ie
> showing this via the requery and the continuous option on the subform)
> and standing by for input. In the other case, the requery refuses to
> display in the continuous subform showing one blank record (really a
> partial record). With the parent form filled in, I can manually
> trigger the query and see it has the correct records.
>
> Does anyone know of some obscure setting or restriction that I need to
> tweak to get the blasted thing to work?
>
> Thanks,
>
> Dave


Allen,

Yes, you are correct and I believe the criteria you mention would
allow me to use form/subform linked fields, but it's not obvious what
I should do. (I'm guessing the original form (that works) was
generated by an Access wizard -- possibly the former database
architect, but not likely -- and I'm trying to manually duplicate that
as an inexperienced form builder.)

On the main form I have a set of master fields. I want the subform to
display the subset of records equivalent to the select query where the
two fixed master fields are chosen by the user on the main form.

How would the linked fields approach be setup? I tried to eliminate
the query by linking both forms to the table and then linking the two
fields in the main form to the subform. The two fields don't actually
appear in the subform. There are actually row source queries on combo
boxes for some of the subform fields since they do double duty as
display slots for existing records and entry of new data for the next
user defined record. According to what I understand, when I enter the
linked master fields the form should display all related records?
This doesn't seem to work so I've still got some screwed up somewhere.

Dave

Nov 13 '05 #4
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<41**********************@per-qv1-newsreader-01.iinet.net.au>...
Hi Dave

I'm not really clear here - esp. about the combos in the subform. If you are
trying to use the non-bound column of the combo in the LinkChildFields of
the subform control, it might be better to a use a query as the RecordSource
of the subform, and include the combo's table so that the field you need to
link on is in the RecordSource.

If you need an example of how subforms work, open the Northwind sample
database, and look at the Customer Orders form. The first subform - Customer
Orders Subform1 - has CustomerID in both the LinkMasterFields and
LinkChildFields, so the subform shows the records matching the CustomerID in
the main form. The 2nd subform - Customer Orders Subform2 has its
LinkChildFields set to OrderID, and its LinkMasterFields set to
[Customer Orders Subform1].Form![OrderID]
That means that its records will match the OrderID in the other subform.

Hopefully that example demonstrates what needs to go into the
LinkChildFields/LinkMasterFields in your example. If you can get the fields
into the source query, it is simplest and most stable.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave Boyd" <da**********@boeing.com> wrote in message
news:e7*************************@posting.google.co m...
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainForm!SomeTextbox
and the problem is that this does not always load/stay up to date
correctly.

Would it be possible to use the LinkMasterFields/LinkChildFields
properties
of the subform instead? That should make life simpler if it is possible,
and
it works for most things unless you are choosing a range rather a
discreet
value (e.g. from start date to end date), or trying to get all values
when
some of the controls in the linkage may be null.

Another alternative is to reassign the RecordSource of the subform in the
Current event of the main form. By creating a SQL string that
concatenates
any literal values into the string, you can handle ranges, ignore nulls,
and
get the exact result you want. You may need to check that Access does not
become overhelpful and decide to assign values to the
LinkMasterFields/LinkChildFields based on the new RecordSource. And you
also
have to be careful to avoid cyclic dependencies, such as something in the
main form that is dependent on something in the subform. Conditional
formatting can also trigger this.
"Dave Boyd" <da**********@boeing.com> wrote in message
news:e7*************************@posting.google.co m...
>
> I have two very similar forms each with a subform. The main form gets
> a few fields from the user and passes this back to a query that the
> subform is bound to. The requery is done when the user enters the
> last qualifying field on the main form.
>
> In one case this works fine, the subform shows the data the user wants
> to update -- which means showing all the data put in previously (ie
> showing this via the requery and the continuous option on the subform)
> and standing by for input. In the other case, the requery refuses to
> display in the continuous subform showing one blank record (really a
> partial record). With the parent form filled in, I can manually
> trigger the query and see it has the correct records.
>
> Does anyone know of some obscure setting or restriction that I need to
> tweak to get the blasted thing to work?
>
> Thanks,
>
> Dave


Allen,

Yes, you are correct and I believe the criteria you mention would
allow me to use form/subform linked fields, but it's not obvious what
I should do. (I'm guessing the original form (that works) was
generated by an Access wizard -- possibly the former database
architect, but not likely -- and I'm trying to manually duplicate that
as an inexperienced form builder.)

On the main form I have a set of master fields. I want the subform to
display the subset of records equivalent to the select query where the
two fixed master fields are chosen by the user on the main form.

How would the linked fields approach be setup? I tried to eliminate
the query by linking both forms to the table and then linking the two
fields in the main form to the subform. The two fields don't actually
appear in the subform. There are actually row source queries on combo
boxes for some of the subform fields since they do double duty as
display slots for existing records and entry of new data for the next
user defined record. According to what I understand, when I enter the
linked master fields the form should display all related records?
This doesn't seem to work so I've still got some screwed up somewhere.

Dave


Allen,

Thanks for your patience. I tried your second solution of changing
the recordsource in the handling code and found it easiest to use the
AfterUpdate? event for the "last" field on the main form. This is
where the requery that didn't work was anyway. (Using the current
event got me in a world of brown goo that fired at the wrong time or
complained about not being able to change focus etc.)

The trick (for me) was to find the recordsource property for the
subform to allowing setting it in the running code rather than at
subform design time. The subform path you might expect leads to the
main form/subform link property sheet and has no recordsource (for GUI
beginners this is the bizarre sequence where clicking on the subform
gives this linkage property set and clicking again --with a resulting
black square-- gives the subform property set). However, the
CodeContextObject.[subform name].Form.RecordSource path allowed me to
move in the SQL query to the sweet spot and CodeContextObject.[subform
name].requery now works.

You were right on that the query wasn't up to date, but just why still
eludes me. Thanks for your help!

Dave
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fionnbarr Kennedy | last post by:
Hi all I have posted this problem before but am having no joy! I have an app written in Access 2000 which is based around a Form/Subform. The problem is with a new XP box only - the same app...
2
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value...
9
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
2
by: Reginald Bal | last post by:
Hello, I created a main form with 2 subforms. In an attempt to move to the next record (or new record) on the main form I get the error " Method 'requery' of object '_Subform' failed". The...
11
by: mrowe | last post by:
I am using Access 2003. (I am also using ADO in the vast majority of my code. I recently read a post that indicated that ADO is not all that is was initially cracked up to be. In the back of my...
3
by: virtualgreek | last post by:
Dear all, I have a scenario that is driving me nuts. (MS Access 2003) I have a form/subform (Continuous form) where it gets its data from tables Order and Order_Details. In the footer...
2
by: DeanL | last post by:
Hi everyone, I have a subform in datasheet view that is used to display the contents of a single table. I have another subform with a query feeding it to give a count of how many particular...
10
beacon
by: beacon | last post by:
Hi everybody, This is probably going to sound unorthodox, but I have to log records that are deleted...I know, go figure. Anyway, I have a form with a (continuous) subform, and on the subform I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.