linking form data to other form txtboxes

  • Thread starter pclis007 via AccessMonster.com
  • Start date
P

pclis007 via AccessMonster.com

I have a form [frmCompanyBase] that updates a company name, address etc.
Assuming one company per copy of the program, I want for example the company
name entered on that form linked to all reports and forms in the DB. I tried
linking the txtbox on a given form to the txtbox in [frmCompanyBase], but if
that form isn't open, then it doesnt work. Also tried linking to the
underlying table for [frmCompanyBase]. Doesn't work. If nothing else,
thinking of keeping that [frmCompanyBase] open upon opening the DB, then
trying to hide it, but can't figure that one out either. Any suggestions,
solutions? The simpler the better.

Thanks
 
J

Jeanette Cunningham

Hi pclis007
Use an unbound textbox on each form and report.
Create a new module and call it something like modPublicProps.
Copy the following code.
---------------------------
Option Compare Database
Option Explicit

Private mvarTheCompany as Variant


Public Property Get TheCompany() As Variant
If IsEmpty(mvarTheCompany) Then
mvarTheCompany= nz(DLookup("[CompanyNameField]", "tblYourTable"),"")
End If

TheCompany= mvarTheCompany
End Property



Public Function TheCompanyName() As String
TheCompanyName = TheCompany
End Function
---------------------------------------

Note: replace CompanyNameField and tblYourTable with your names


For each unbound textbox, put its control source equal to TheCompanyName

=TheCompanyName()

note: include the parentheses at the end of TheCompanyName



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Top