Why is query empty?

P

Pamela

I was advised to create a query from which I can base a report. The report
(and so the query) needs to show info from approx 10 related tables. My
ultimate goal is to have a command button on a data entry form that when
clicked will print all of the data that was input for that record (in all
related tables) which is in the report I have. My query, however, is coming
up empty and therefore my report is blank. Are there any restrictions or
other aspects to this that I'm missing? Any suggestions or alternatives to
accomplishing this goal? Here is the code I have for the button:
Private Sub PrintrptAssn_Click()
On Error GoTo Err_PrintrptAssn_Click
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptAssignment", acViewPreview, , , , "[InspectionID] = " &
[InspectionID]
Exit_PrintrptAssn_Click:
Exit Sub
Err_PrintrptAssn_Click:
MsgBox Err.Description
Resume Exit_PrintrptAssn_Click
*Note, I have temporarily changed the code to just open the report for now
so that I don't keep printing blanks.

Any help anyone can give would be great! Thanks
 
T

Tom van Stiphout

On Mon, 19 Jan 2009 20:23:01 -0800, Pamela

If you are in the process of entering a new record, it would not yet
be in the table and that would cause the query to return 0 records.
If you're talking about an existing record, then most likely with a
query over 10 tables you have made some mistake that (in hindsight)
explains why there is no data. Make a copy of the query and reduce its
complexity by taking out tables until it starts returning data. That
last table that you removed does not have records for the foreign-key
value. If that's to be expected, you need to use an outer join.

-Tom.
Microsoft Access MVP
 
J

John W. Vinson

I was advised to create a query from which I can base a report. The report
(and so the query) needs to show info from approx 10 related tables. My
ultimate goal is to have a command button on a data entry form that when
clicked will print all of the data that was input for that record (in all
related tables) which is in the report I have. My query, however, is coming
up empty and therefore my report is blank. Are there any restrictions or
other aspects to this that I'm missing?

If the joins in your query are all the default Inner Join, then you must have
matching data in every single one of the ten tables to see any data at all. If
there are some tables which might legitimately have no records for that
particular ID, then you'll need to select the Join lines in query design view
and choose one of the Outer Join options - "Show all records in TableA and
matching records in TableB".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top