Hi Guys,
I have a combo box that when I select an item in the list, I would like it to refresh two other combo boxes. A query runs that creates a table with new data the old data is deleted. The combo boxes then use this table data as a rowsource.
The the main combobox is cboCustomer and the two comboboxes I need refreshed are cboFleet and cboTyreSize.
Not being very good at coding I tried the following:
Private Sub cboCustomer_AfterUpdate()
On Error GoTo ErrorHandler
Dim stDocName As String
Me.cboFleet.RowSource = ""
Me.cboFleet.Value = ""
stDocName = "qmakVehicles"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Me.cboFleet.RowSource = "SELECT DISTINCTROW tblFleetDD.FltNbr FROM tblFleetDD ORDER BY tblFleetDD.FltNbr;"
Me.cboFleet.Requery
Dim stDocName As String
Me.cboTyreSize.RowSource = ""
Me.cboTyreSize.Value = ""
stDocName = "qmakTyreSize"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Me.cboTyreSize.RowSource = "SELECT tlkpCasingSize.CsngSz FROM tlkpCasingSize ORDER BY tlkpCasingSize.CsngSz;"
Me.cboTyreSize.Requery
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
Resume ErrorHandlerExit
End Sub
I also wish for the messages to be suppressed when rebuilding the data for the tables and for the tables to be updated without any questions being asked.
Any suggestions will be appreciated.
Hayton McGregor
I have a combo box that when I select an item in the list, I would like it to refresh two other combo boxes. A query runs that creates a table with new data the old data is deleted. The combo boxes then use this table data as a rowsource.
The the main combobox is cboCustomer and the two comboboxes I need refreshed are cboFleet and cboTyreSize.
Not being very good at coding I tried the following:
Private Sub cboCustomer_AfterUpdate()
On Error GoTo ErrorHandler
Dim stDocName As String
Me.cboFleet.RowSource = ""
Me.cboFleet.Value = ""
stDocName = "qmakVehicles"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Me.cboFleet.RowSource = "SELECT DISTINCTROW tblFleetDD.FltNbr FROM tblFleetDD ORDER BY tblFleetDD.FltNbr;"
Me.cboFleet.Requery
Dim stDocName As String
Me.cboTyreSize.RowSource = ""
Me.cboTyreSize.Value = ""
stDocName = "qmakTyreSize"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Me.cboTyreSize.RowSource = "SELECT tlkpCasingSize.CsngSz FROM tlkpCasingSize ORDER BY tlkpCasingSize.CsngSz;"
Me.cboTyreSize.Requery
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & _
Err.Description
Resume ErrorHandlerExit
End Sub
I also wish for the messages to be suppressed when rebuilding the data for the tables and for the tables to be updated without any questions being asked.
Any suggestions will be appreciated.
Hayton McGregor