M
meznak
I have three combo boxes on a form displaying Type, Make, and Model of
machine in the selected record. I only have Model stored in the
record (in tblServers) and the form should pull Type and Make from
another table (tblModel). I am able to get that working by setting
"Control Source = Model" for cbxType and cbxMake. That works for
displaying existing records, but not well for entering new records.
When creating a new record, I want to be able to select Type,
filtering cboMake; select Make, filtering cboModel. I am able to get
this working with the following code:
Private Sub cbxType_AfterUpdate()
Dim strSQL As String
'This function sets the RowSource of cbxMake, based on the
'value selected in cbxType.
sSQL = "SELECT DISTINCT Make " _
& " FROM tblModel WHERE Type = '" & Me.cbxType _
& "' ORDER BY Make"
Me!cbxMake.RowSourceType = "Table/Query"
Me!cbxMake.RowSource = sSQL
(repeated/tweaked for cbxMake)
That function only works when I unbind the combos. I would very much
like to have both functions work on the same form. Does anyone have
suggestions on how to do this?
machine in the selected record. I only have Model stored in the
record (in tblServers) and the form should pull Type and Make from
another table (tblModel). I am able to get that working by setting
"Control Source = Model" for cbxType and cbxMake. That works for
displaying existing records, but not well for entering new records.
When creating a new record, I want to be able to select Type,
filtering cboMake; select Make, filtering cboModel. I am able to get
this working with the following code:
Private Sub cbxType_AfterUpdate()
Dim strSQL As String
'This function sets the RowSource of cbxMake, based on the
'value selected in cbxType.
sSQL = "SELECT DISTINCT Make " _
& " FROM tblModel WHERE Type = '" & Me.cbxType _
& "' ORDER BY Make"
Me!cbxMake.RowSourceType = "Table/Query"
Me!cbxMake.RowSource = sSQL
(repeated/tweaked for cbxMake)
That function only works when I unbind the combos. I would very much
like to have both functions work on the same form. Does anyone have
suggestions on how to do this?