473,722 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7016
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainF orm!SomeTextbox
and the problem is that this does not always load/stay up to date correctly.

Would it be possible to use the LinkMasterField s/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
LinkMasterField s/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**********@b oeing.com> wrote in message
news:e7******** *************** **@posting.goog le.com...

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*********@Se eSig.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!YourMainF orm!SomeTextbox
and the problem is that this does not always load/stay up to date correctly.

Would it be possible to use the LinkMasterField s/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
LinkMasterField s/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**********@b oeing.com> wrote in message
news:e7******** *************** **@posting.goog le.com...

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 LinkMasterField s 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 LinkMasterField s 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/LinkMasterField s 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**********@b oeing.com> wrote in message
news:e7******** *************** **@posting.goog le.com...
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainF orm!SomeTextbox
and the problem is that this does not always load/stay up to date
correctly.

Would it be possible to use the LinkMasterField s/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
LinkMasterField s/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**********@b oeing.com> wrote in message
news:e7******** *************** **@posting.goog le.com...
>
> 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*********@Se eSig.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 LinkMasterField s 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 LinkMasterField s 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/LinkMasterField s 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**********@b oeing.com> wrote in message
news:e7******** *************** **@posting.goog le.com...
I think your subform is bound to a query that contains criteria such as:
Forms!YourMainF orm!SomeTextbox
and the problem is that this does not always load/stay up to date
correctly.

Would it be possible to use the LinkMasterField s/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
LinkMasterField s/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**********@b oeing.com> wrote in message
news:e7******** *************** **@posting.goog le.com...
>
> 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
CodeContextObje ct.[subform name].Form.RecordSou rce path allowed me to
move in the SQL query to the sweet spot and CodeContextObje ct.[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
2070
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 runs fine on all others. The subform is displaying the #Error symbol: closing and re opening it solves the problem. Compact/Repair doesn't work, creating a new database and importing the objects doesn't work either. Re creating the form worked...
2
4764
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 in the field of the last record entered on the subform. But what its doing is referencing whatever record the user clicked on last before closing all the forms. Also if the user cleared the subform field, I would like the text box on the main...
9
3336
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 sub form (code in the AfterUpdate Event). Here's the issue. If the user deletes a subform record. The field on the main form shows null even if there is a value in the preceding subform record. What I'd like it to do is immediately refresh to
20
10822
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 either an option button plus two text fields or a checkbox plus two text fields Am wanting to save the user entries into an underlying table. Tag property for each option button, check box or text field has the value of the key
2
6067
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 database closes after answering the popup window (Microsoft Access has encounterd a problem and needs to close. .....) Does anybody has an idea why I'm having this problem?
11
7174
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 mind I am wonder if this is causing my problem, but I don’t want to go through the work to convert to DAO unless I know it is truly in my best interest.) I am having problems getting a requery to show up consistently on a couple of forms. I have...
3
2409
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 section of the subform I have a hidden textbox named txtOrder_Total_Amount which displays the total of the whole order. On the main form I have a bound contol from the Order table, namely Order.Order_Total_Amount_Euro On the subform I have fields such...
2
2016
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 items are in the table and wanted to ask how I go about updating the count when I delete a value from the datasheet subform without closing and reopening the form? Many thanks for any help you can offer...
10
7166
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 have a command button, called cmdDelete, that launches a dialog form, called frmDeleteCurrentRecord, where the user has to enter their name and a reason. I have managed, through a ton of trial and tribulation, found a way to delete the current...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9382
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9236
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9087
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8043
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5995
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.