DataBase - Acc 2007 Subform Recordset vs Acc 2002 Subform Recordset

Asked By dbqph
31-Jan-10 03:36 PM
I have created a form/subform combo in Access 2002 and have some code in the
OnCurrent section of the form that changes the recordsource of the subform
that will either:

1. Return records for a people at an address (default recordset), or,
2. Return records for an individual at an address

In a nutshell:

If Forms![frmFindBidderCheckout].[LocateBasketsBy] = 2 Then
' Guest wants bidders by address
Me.[frmBidderCheckOut].Form.RecordSource = "qryBasketsByBidderAddress"
Else
' Get just the bidder baskets
Me.[frmBidderCheckOut].Form.RecordSource = "qryBasketsByBidderID"
End If

Me.[frmBidderCheckOut].Form.Requery

intBasketCount = Nz(DCount("[GuestID]",
Me.[frmBidderCheckOut].Form.RecordSource), 0)
curAmountDue = Nz(DSum("[WinningBidAmount]",
Me.[frmBidderCheckOut].Form.RecordSource), 0)

In Access 2002, the correct number of records is returned for either
scenario. In Access 2007, the subform only displays the second case... almost
as if there is a inferred "Link Child/Link Master" setting on the subform
control (there is not).

However, in either version of Access, the values of intBasketCount and
curAmountDue are correct.

Is there a better/different way to properly refresh the content of my
subform in Access 2007 that will correctly display the contents of the
recordsource for the subform? I am open for any/all suggestions.

TIA,

dbqph
Access 2007
(1)
QryBasketsByBidderID
(1)
QryBasketsByBidderAddress
(1)
TblGuests2.AddressID
(1)
TblGuests.AddressID
(1)
TblGuests2.GuestID
(1)
TblBaskets.GuestID
(1)
TblGuests.GuestID
(1)
  Jeanette Cunningham replied to dbqph
31-Jan-10 10:27 PM
Not sure that I have ever noticed a subform with incorrect number of records
in A2007.
One thing with your code, after you set the subform's record source, you
should not do a requery.
The line
Me.[frmBidderCheckOut].Form.RecordSource = "qryBasketsByBidderID"
sets the record source for you and the requery is completely unnecessary.
I do not expect this would make any difference to your results.

In A2007 there are additional properties for forms, not found in A2002.
Examples - Filter On Load, Order By On Load - you could check if any of
these make any difference.

Perhaps some other code on your main form or subform is interferring with
the record source in the subform.

Another way to do what you want is to use 2 different subforms - one for the
people and the other for an individual.
You can set the subform control's correct source object (one of the
subforms) depending on the value of LocateBasketsBy instead of changing the
record source of the subform.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
  dbqph replied to Jeanette Cunningham
03-Feb-10 01:19 AM
Hi Jeanette,

Thank you for the suggestions. I was forcing a requery because I was
wondering if Access was (for some reason) not returning the correct number of
records. Here is an abbreviated scenario:

1. I have a Guests table (GuestID, GuestName, AddressID):
1, John Doe, 1
2, Jane Doe, 1
3, Bob Smith, 2
4, Betty Smith, 2
2. I have an Address table (AddressID, Address):
1, 123 Any Street
2, 456 Easy Street
3. I have a "Basket" table (BasketID, BasketName, GuestID):
1, Basket1, 1
2, Basket2, 1
3, Basket3, 2
4, Basket4, 3

I am writing the database for a charity event. By default, the database
prompts for a primary bidder and will anticipate that this winning bidder
will also pay for the baskets won by his/her spouse. For example, Guest1
(John Doe) will also pay for Jane Doe's basket. The query that I am using to
perform this is similar to:

SELECT tblBaskets.GuestID, tblGuests.AddressID
FROM tblBaskets LEFT JOIN tblGuests ON tblBaskets.GuestID = tblGuests.GuestID
WHERE (((tblBaskets.GuestID) In (SELECT tblGuests2.GuestID FROM tblGuests
LEFT JOIN tblGuests AS tblGuests2 ON tblGuests.AddressID=tblGuests2.AddressID
WHERE tblGuests.GuestID=Forms!frmFindBidderCheckout!BidderID GROUP BY
tblGuests2.GuestID));

Am I over-thinking this? FWIW, my other query is simply:

SELECT tblBaskets.GuestID, tblGuests.AddressID
FROM tblBaskets LEFT JOIN tblGuests ON tblBaskets.GuestID = tblGuests.GuestID
WHERE (((tblBaskets.GuestID)=[Forms]![frmFindBidderCheckout]![BidderID]));

When I open the underlying query and subform by themselves, they return the
correct number of records (3 in my example data above). However, when I open
the form/subform combo, my subform only returns two records (the records
associated with the main bidder).

I looked through the controls for the form in Acc 2007 and did not see
anything that lept out at me. Also, I commented out the Requery statement and
that did not have any effect as you surmised. Again, this all works correct in
Acc 2002.

I will keep checking... thank you for your insights and any others that come
to mind.

dbqph
Create New Account
help
more confused I get. Looking forward to getting a new toy though! Cheers The Frog Access Discussions Larry Linson Microsoft Office Access MVP Co author Microsoft Access (1) James A. Fortune CDMAPoster (1) Visual Studio 2010 (1) Entity Framework (1) Microsoft Excel 1) Microsoft Word (1) Office 2010 (1) Access 2007 (1) No. There is a free Access 2007 / 2010 runtime you can download and distribute. Reuse. Still works. Mind you not for the web version of Access 2010 which only has macros. Tony - - Tony Toews, Microsoft Access MVP Tony's Main MS
seconds to load. There is a possible reason, it reads from a local MDB file (access), and it reads from some 270000 rows (result some 15-20 rows, where the highest are counted 150000, 50000, 40000, 26000, remaining are 100's). This is probably more Access that Visual Studio, though - is there a way to split it up or cancel the code takes less that 0.1 second. So the query is what slows it down. Access Discussions SQL Server (1) Linson Unlike Albert D. Kallal (1) MySQL (1) Windows Server 2003 help for this task. And an appropriate index might help to avoid the full table access. By the way, grouping by a.event_id in conjunction with count(a.event_id) makes no not, each and every record needs to be loaded and compared. The JET engine behind Access is not suited to handle databases beyond stamp collection size and lacks most features of should restrict your post to the dotnet / csharp newsgroups, so those in comp.databases.ms-access who _do_ know about Jet and Ace will not see and correct your erroneous claims. Larry Linson Microsoft Office Access MVP Co-Author, "Microsoft Access Small Business Solutions", Wiley, 2010 Utter rubbish and utter nonsense. If a index is available
Data Macros Don't Work With Linked Tables??? DataBase I have an Access 2010 ACCDB with an AfterInsert data macro on a table. Works fine. However, when I end and back end file open, just in case that was an issue. Thanks! Neil Access Discussions Windows SharePoint Services (1) SQL Server (1) Access 2.0 (1) SharePoint (1) Outlook 2007 (1) Access 2010 (1) Access 2003 (1) Outlook (1) I should note that I am using the data macro to different here, but those triggers fire + run, and in fact they fire + run without even Access having been installed. Of course the other application open to the back end would have opening the back end, and in the past for 18 years, when you opened a Access application because you had some linked tables, that NEVER suggested or enabled you could run
focus on the tab w / o using sendkeys. Anyone know? it is obviously used by Access' internal mechanisms somewhere but does not seem like that functions are exposed for us users. . er ah 'developers'. Access Discussions IHTMLDocument (1) SQL Server (1) MySQL (1) Microsoft Word (1) Visual Studio (1) SharePoint 1) Silverlight (1) When Microsoft says "developers, " they are really thinking of .NET developers, not Access developers :-). See: http: / / groups.google.com / group / microsoft.public.dotnet.languages.csharp / msg = / 695c265597d62a6b Maybe it is possible to use the unmanaged API from Access to gain control of the Ribbon's buttons. I believe there is also an API THEN to be used for a considerable amount of times over = and = 20 over? sendkeys. Access 2010 and the new ribbon does allow VBA to set what tab is active. = (access 2007 does not have this ability) However, I not sure why you would need to do for the report would do the trick, and = this = 20 would work well for both 2007 or 2010. - - = 20 Albert D. Kallal (Access MVP) Edmonton, Alberta Canada Pleasenospam_kallal@msn.com = 20
that I want to come out with a Mac version of our software as our Access 2003 application is presently running fine with Parallels). I just spent a bunch of time how it works and what exactly it does. Does it have a programming language like Access has VBA? What kind of applications can be built and distributed? I do like how also run devices like an iPhone and iPad. Again, I am just being curious. -paulw Access Discussions SQL Server (1) MySQL (1) SharePoint (1) Albert D. Kallal (1) Access 2003 (1) Access 2010 (1) Silverlight (1) Excel (1) Oh, and it also builds web applications unlike Access. Just being curious! Why not ask at a forum which focuses on filemaker? bob I am looking for a comparison to MS Access from an Access developer's point of view. It surely can not be as powerful as Access? You