First of all, thank you in advance for any help anybody can give me on this. I will try to explain my problem the best I can.
I am designing a databse to track maintenance we do for various companies.
When I click on a button on the main menu, it opens up a form with 2 combo boxes. I don't want any selections from the second box to occur until I've made a selection from the first box. The code for this button is:
Private Sub ViewFiltered_Click()
DoCmd.Close
DoCmd.OpenForm ("frmAllRecords")
[Forms]![frmAllRecords]![Label29].Caption = "View/Modify Records"
[Forms]![frmAllRecords]![CompanyName].RowSource = "SELECT [tblCompanies].[Company] FROM [tblCompanies];"
End Sub
The table "tblCompanies" has a list of the companies, and the first combo box selects the company name from a drop down list. The second combo box selects the company number.
The first combo box has thed following code on Change:
Private Sub CompanyName_Change()
[Forms]![frmAllRecords]![CompanyNumber].RowSource = "SELECT [tblMaintenanceLog].[CompanyNumber] FROM [tblMaintenanceLog] WHERE [tblMaintenanceLog].[CompanyName]=[Forms]![frmAllRecords]![CompanyName];"
End Sub
The second box has the following on Change:
Private Sub CompanyNumber_Change()
[Forms]![frmAllRecords]![Address].ControlSource = "Address"
[Forms]![frmAllRecords]![Province].ControlSource = "Province"
[Forms]![frmAllRecords]![City].ControlSource = "City"
[Forms]![frmAllRecords]![PostalCode].ControlSource = "PostalCode"
End Sub
I am able to select data from each combo box, but the issue is it always goes to the first record in the table. I want it to go to whatever record has the information I.ve selected for Company Name and Number.
If this is not enough information, please let me know. I really appreciate any help.
Thank you.
comteck