DAO - assign ControlSource for textbox

sjr1917

Registered User.
Local time
Today, 07:13
Joined
Dec 11, 2012
Messages
47
In a Report I'm using DAO to pull some header data from a Company table.
Assigning the value of a field (like Company Name) to the Caption of a label works just fine. But one field is variable text and may need to grow, so I'm using a textbox (txtDescription).

The code below throws an error (You can't assign a value to this object)... the textbox. So how do I set the ControlSource to the field "CoDescription" in the open rowset: rst?

Code:
Dim dbs As DAO.Database
  Dim rst As DAO.Recordset
  Set dbs = CurrentDb
  Set rst = dbs.OpenRecordset("tblCompanyData")
  
  Me.lblCoName.Caption = rst!Company
  Me.txtDescription.Value = rst!CoDescription
 
Pat,
The Join option makes sense. That certainly would work. It just seems inefficient... having to tack header data on to each detail row, when it's only needed at the top of each report.

Talk some more about the difference between Open & Load. I thought that you added code related to setting rowsets to be used in onOpen so that when the load event triggered the definitions would be there ready to use??
 
Thanks, Pat.
Your comments about open vs load clarified that issue!
And your "= forms!someform!somehiddencontrol" just turned on the light.
Thanks.
 

Users who are viewing this thread

Back
Top Bottom