How to reference control on Main form from query (1 Viewer)

Lateral

Registered User.
Local time
Yesterday, 18:05
Joined
Aug 28, 2013
Messages
388
Hi guys

I've been trying to figure this out but am struggling.

I have a form that displays a list of outstanding Workorders (these are basically invoices) in Continuous Forms mode. There is lots of information displayed including name, address and of course the unique Workorder number displayed. This form is called "fAll Valid Workorders Owing Money"

There is a command button that when clicked, uses VBA to do some stuff and then create a PDF version of the invoice that is then emailed out to the customer.....this has been working well.

I decided to create another form, called "fStartForm" and create 3 tabs.

I then attached the "fAll Valid Workorders Owing Money" form to the first tab (lets call it Page1).

Ok, here's the issue.

Everything works well EXCEPT the part where it creates the PDF file.

I think the issue is because the query within the PDF report attempts to find the "WorkorderID" from ""fAll Valid Workorders Owing Money" using the following but can't because of the fact that it is in a Tab control on the "fStartForm":

[forms]![fAll Valid Workorders Owing Money].[WorkorderID]

I have tried to change the above to correctly reference the [WorkorderID] but just can't seem to figure it out....I'm missing something.

I hope I have explained myself clearly.

Your help is very much appreciated.

Cheers
Greg
 

speakers_86

Registered User.
Local time
Yesterday, 21:05
Joined
May 17, 2007
Messages
1,919
Try this: forms!fStartForm.[fAll Valid Workorders Owing Money].form.WorkOrderID The fAll Valid... form exists as a child of the parent form, not as an object in the forms collection.
 

Lateral

Registered User.
Local time
Yesterday, 18:05
Joined
Aug 28, 2013
Messages
388
Hi mate

I tried it but it did not work.

It prompts me to manually enter the WorkorderID as per the attached screen shot.

Here is the entire SQL code:

SELECT Customers.*, Workorders.*, Employees.LastName & ", " & Employees.FirstName AS [Employee Name], [Customers].[ContactFirstName] & " " & [Customers].[ContactLastName] AS [Contact Name], Customers.EmailAddress, Customers.MobNumber, Customers.EmailAddress, Customers.Web_Customer_Number
FROM Customers INNER JOIN (Employees RIGHT JOIN Workorders ON Employees.EmployeeID = Workorders.EmployeeID) ON Customers.CustomerID = Workorders.CustomerID
WHERE (((Workorders.WorkorderID)=[forms]![fStartForm].[fAll Valid Workorders Owing Money].[form].[WorkOrderID]));

Any other ideas?

Cheers
Greg
 

Attachments

  • workorder01.png
    workorder01.png
    26.6 KB · Views: 53

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:05
Joined
Jan 20, 2009
Messages
12,852
Code:
[forms]![fStartForm].[fAll Valid Workorders Owing Money].[form].[WorkOrderID]

Is [fAll Valid Workorders Owing Money] the name of the subform control? It needs to be the control name not the SourceObject (form name). The form wizard makes them the same but they can be different.
 

Lateral

Registered User.
Local time
Yesterday, 18:05
Joined
Aug 28, 2013
Messages
388
Hi Galaxiom

I figured out what the issue was.

The name setting under the Other Property was not "fAll Valid Workorders Owing Money" so therefore the query couldn't find it.

Once I changed it to "fAll Valid Workorders Owing Money"....problem solved!

Thanks for your help....it's a trap to remember....

Cheers
Greg
 

Users who are viewing this thread

Top Bottom