Combo-box values automatically update
        Posted  
        
            by glinch
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by glinch
        
        
        
        Published on 2010-03-30T18:03:11Z
        Indexed on 
            2010/03/30
            18:13 UTC
        
        
        Read the original article
        Hit count: 479
        
ms-access
|ms-access-2007
Hi all, hopefully somebody can help
The table structure is as follows:
tblCompany:   
compID
compName
tblOffice:  
offID,
compID,   
add1, add2, add3 etc...
tblEmployee:   
empID
Name, telNo, etc...   
offID
I have a form that contains contact details for employees, all works ok using after update. A cascading combo box, cmbComp, allows me to select a company, and inturn select the appropriate office, cboOff, and updates the corresponding tblEmployee.offID field correctly. Fields are automatically updated for the address also
cmbComp: RowSource
SELECT DISTINCT tblOffice.compID, tblCompany.compID 
FROM tblCompany 
INNER JOIN AdjusterCompanyOffice 
ON tblCompany.compID=tblOffice.compID 
ORDER BY tblCompany.compName; 
cboOff: RowSource
SELECT tblCompany.offID, tblCompany.Address1, 
tblCompany.Address2, tblCompany.Address3, tblCompany.Address4, 
tblCompany.Address5 
FROM tblCompany 
ORDER BY tblCompany.Address1; 
The problem I am having is that when i load a new record how to retrieve the data and automatically load the cmbComp and text fields.
The cboOff combo box loads correctly as the control source for this is the offID
I imagine there must be a way of setting the value on opening the record? Not sure how though. I dont think I can set the controlsource cmbComp or text fields, or can I?
Any help/point in the right direction appreciated, have been searching for a way to do this but cant get anywhere!
© Stack Overflow or respective owner