By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,476 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,476 IT Pros & Developers. It's quick & easy.

Only printing first 2 records of query

P: 5
Hi All,
I've got a Recordset that stores a summary (no duplicates) of a field in a query.

This particulary field gives the index for the query/report that needs to be called, ie:
1. I have a number of records that are of interest (pulled from the dB from a query)
2. Each record in dB has a type, this type is the trigger for the query/report that needs to be run for it
3. There are 16 types
4. The recordset may not contain all 16 types.
5. I created a summary of which types are in the recordset
6. I only want to call the relevant query/reports
7. I have done this with a case statement

The issue is where the call is made to open the query and then open the report(in printpreview), I ony get the first 2 records from the query appearing in the report:


iDisplayType = 2
.
.
.
.
.
Case Is = 17
DoCmd.OpenQuery ("17 - General AO")
DoCmd.OpenReport "17 - General AO", iDisplayType

Can someone please let me know what is going on and why I'm only getting the first 2 elements
Jan 6 '12 #1
Share this Question
Share on Google+
7 Replies


P: 5
I have just subscribed to this thread
Jan 6 '12 #2

Rabbit
Expert Mod 10K+
P: 12,315
We need to see the query.
Jan 6 '12 #3

P: 5
SQL of parent Query:
SELECT CommRefQuery.InstallCompl, CommRefQuery.CommDocCirc, CommRefQuery.CommComplete, CommRefQuery.CommisioningItem, CommRefQuery.PTermR, CommRefQuery.ExtTag, CommRefQuery.SectInd1, CommRefQuery.[Comm Sht Ind], CommRefQuery.Type, CommRefQuery.Description, CommRefQuery.InstallComplDate, CommRefQuery.MechFICReq, CommRefQuery.MechFICPerformed, CommRefQuery.CommDocCirc, CommRefQuery.CommDocCircTo, CommRefQuery.CommDocCircDate, CommRefQuery.CommDocRcv, CommRefQuery.CommDocRcvDate, CommRefQuery.CommCompleteDate, CommRefQuery.Cabinet
FROM CommRefQuery
WHERE (((CommRefQuery.CommDocCirc)<>Yes));


SQL of query who's report is only printing 2 records:
SELECT CommChkShtGenQuery.ExtTag, CommChkShtGenQuery.PTermR, CommChkShtGenQuery.[Comm Sht Ind], CommChkShtGenQuery.Description, CommChkShtGenQuery.Type, CommChkShtGenQuery.Cabinet
FROM CommChkShtGenQuery
WHERE (((CommChkShtGenQuery.[Comm Sht Ind])="19"));


All queries of this nature have the same error (the only difference is the [Comm Sht Ind] value they are pulling out.

If you need more info, please let me know.

Regards
Darryl
Jan 6 '12 #4

P: 5
I Should also mention that if I step through the code line, by line there is no problem, but if I run straight past the OpenReport line, then there is a problem.

I have no idea what is going on.

I were using a proper language, I'd compare the machine code from both the debug and non-debug compiles and see what's going on, but being a relative VBA noob, I'm more than a little stuck.

Regards
Darryl
Jan 6 '12 #5

Rabbit
Expert Mod 10K+
P: 12,315
Is there a reason you open the query before opening the report? Unless it's an action query, there's no need to open it.
Jan 6 '12 #6

P: 5
I open the query so that I can double check that everything has worked properly, it the number of sheets in the print-preview matched the record count.

I don't see how me opening the query prior to the report would change the fact that I only get 2 of the records when not debugging the code.

Regards
Darryl
Jan 7 '12 #7

Rabbit
Expert Mod 10K+
P: 12,315
It could cause a lock on the records if both are attempting to access the same resource at the same time.
Jan 7 '12 #8

Post your reply

Sign in to post your reply or Sign up for a free account.