Set ControlSource for Report Textboxes?

goldenorb82

Registered User.
Local time
Yesterday, 19:20
Joined
Aug 18, 2004
Messages
12
Access newbie here -- i'm sorry if this question has been posted already, but i searched through the existing threads and could not seem to find an answer. My question is rather basic: I have a query constructed by the user assigned to a variable in my module like so:

strQuery = "SELECT [tblCustomer].[CustomerID], [tblCustomer].[CustomerName], [tblCustomer].[Address], [tblCustomer].[Phone], [tblCustomer]., [tblCustomer].[CustomerType], [tblCustomer].[AdditionalComments]
FROM tblCustomer INNER JOIN tblProductCustomer ON [tblCustomer].[CustomerID]=[tblProductCustomer].[Customer]
WHERE [tblProductCustomer].[License] NOT LIKE 'Perpetual'
GROUP BY [tblCustomer].[CustomerID], [tblCustomer].[CustomerName], [tblCustomer].[Address], [tblCustomer].[Phone], [tblCustomer].[Email], [tblCustomer].[CustomerType], [tblCustomer].[AdditionalComments];"

I have created a "template" Report with 7 textboxes and i want to be able to pop up this report on the fly. I first thought this would be like creating a tabular form, where you set the RecordSource of the form to "strQuery" (like frmForm.RecordSource = "strQuery") and each text box's controlSource is set to the columnname (frmForm.txtCustomerID.ControlSource = "tblCustomer.CustomerID").

I have discovered that Reports are not so easy. I can set the RecordSource of the report the same way (i think at least...) but i cannot seem to figure out how to set the ControlSource of each textbox correctly. I need the ControlSource of each textbox on the report to be set to a corresponding column name from the query above. Can someone point me in the right direction please?

Thank you so much!
 
Firstly have you tried using the report wizard?

It will create a report that you can then play around with, it certainly helps when it comes to then figuring out how everything works in reports, it should then become apparent how the source of text boxes are set and you can move on to building your own from scratch. I still use the wizard to start off building many of my new reports.
 
Thanks for your response!
Actually, i have tried working with the wizard and have done exactly as you mentioned -- which is why i want to set the control source of the text boxes. However, these reports need to be dynamic and so i can't actually set the Record source and control source using the "properties" box directly on the report -- i want to use VB to do so instead.

In vb, i could set the record source of the report, but couldn't set the control sources of each text box. However, i should mention that as of last night, i did find a solution to my problem ( i think ) and now i can create a dynamic report and input data through vb, so if anyone needs help with that, i can lend my code to you. it doesn't look very nice still, but i'm working on that.

thanks again!
 

Users who are viewing this thread

Back
Top Bottom