Main form won't print

R

Ron Weaver

I have a form with a subform. The main form has names and dates and the
subform has products. The only way the order will print is if the subform has
an entry in it. I would like to be able to print just the customer info at
times. I have tried putting code in the print command buttons On Click event
(DoCmd.RunCommand acCmdSaveRecord) along with the other print code. Can
someone give me an idea why this is happening?
 
D

Dirk Goldgar

Ron Weaver said:
I have a form with a subform. The main form has names and dates and the
subform has products. The only way the order will print is if the subform
has
an entry in it. I would like to be able to print just the customer info at
times. I have tried putting code in the print command buttons On Click
event
(DoCmd.RunCommand acCmdSaveRecord) along with the other print code. Can
someone give me an idea why this is happening?


Are you running a report to print the data? If so, my guess would be that
the report's recordsource is a query that does an inner join of the main
form's recordsource table with the subform's recordsource table. Such a
query would only return a record when there are matching main-form and
subform records. The solution is to change the query to an outer join,
returning all the records from the main form's source table and only the
matching ones from the subform's source table.
 
R

Ron Weaver

You are correct about the report. When I tried to make the change, I got a
"Join Expression not Supported", and "Ambiguous Outter Join" message??
 
D

Dirk Goldgar

Ron Weaver said:
You are correct about the report. When I tried to make the change, I got a
"Join Expression not Supported", and "Ambiguous Outter Join" message??


It can get tricky if you're joining more thanjust one table. If you'll post
the original SQL of the report's recordsource, maybe we can suggest a
version that will work.
 
R

Ron Weaver

Here it is:
SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName,
Customer.Phone, Orders.OrderID, Orders.Room, Orders.TodaysDate,
Orders.StartDate, Orders.EndDate, Orders.ArriveTime, Orders.StartTime,
Orders.EndTime, Orders.Notes, Products.ProductID, Products.ProductName,
Orders.RoomID, [Order Details].Quanity, [Order Details].Days
FROM (Customer INNER JOIN Orders ON Customer.CustomerID = Orders.CustomerID)
INNER JOIN (Products INNER JOIN [Order Details] ON Products.ProductID =
[Order Details].ProductID) ON Orders.OrderID = [Order Details].OrderID;
Thanks
 
R

Ron Weaver

I tried an additional Join. The form is working now. This is my SQL.
SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName,
Customer.Phone, Orders.OrderID, Orders.Room, Orders.TodaysDate,
Orders.StartDate, Orders.EndDate, Orders.ArriveTime, Orders.StartTime,
Orders.EndTime, Orders.Notes, Products.ProductID, Products.ProductName,
Orders.RoomID, [Order Details].Quanity, [Order Details].Days
FROM (Customer INNER JOIN Orders ON Customer.CustomerID = Orders.CustomerID)
LEFT JOIN (Products RIGHT JOIN [Order Details] ON Products.ProductID = [Order
Details].ProductID) ON Orders.OrderID = [Order Details].OrderID;
Thanks for pointing me in the right direction.

Ron Weaver said:
Here it is:
SELECT Customer.CustomerID, Customer.FirstName, Customer.LastName,
Customer.Phone, Orders.OrderID, Orders.Room, Orders.TodaysDate,
Orders.StartDate, Orders.EndDate, Orders.ArriveTime, Orders.StartTime,
Orders.EndTime, Orders.Notes, Products.ProductID, Products.ProductName,
Orders.RoomID, [Order Details].Quanity, [Order Details].Days
FROM (Customer INNER JOIN Orders ON Customer.CustomerID = Orders.CustomerID)
INNER JOIN (Products INNER JOIN [Order Details] ON Products.ProductID =
[Order Details].ProductID) ON Orders.OrderID = [Order Details].OrderID;
Thanks
Dirk Goldgar said:
It can get tricky if you're joining more thanjust one table. If you'll post
the original SQL of the report's recordsource, maybe we can suggest a
version that will work.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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