I have a split form with cascading combo boxes and other entry fields. The information in the cascading combo boxes is not saving though the rest of the information on the form is. I have also included a graphic of the cascombobox
setup (though not other fields on form as they are working and saving) Also every time I attempt to add a new record, when you change the selection in the cascading combo boxes it changes the information for the first record to match the second record (And it will only allow me to enter 2 records when I need 20+ records)
the save and save & close buttons
"Save"
RunMenuCommand
Command Save Record
RefreshRecord
"Save and Close"
If [Form].[Dirty]
Save Record
end if
Close Window [,,Prompt]
Submacro ErrorHandler
MessageBox (=[MacroError].[Description],Yes,None,)
End Submacro
the code for the cascading combo is:
Option Compare Database
Option Explicit
Private Sub cboCourseNameID_AfterUpdate()
' Filter the list of courses based on the selected information.
FilterDescriptionList
End Sub
Private Sub cboCourseNoID_AfterUpdate()
' Set the Course Name combo box to be limited by the selected Course No
Me.cboCourseNameID.RowSource = "SELECT tblCourseName.CourseNameID, tblCourseName.CourseName FROM tblCourseName " & _
" WHERE CourseNoID = " & Nz(Me.cboCourseNoID) & _
" ORDER BY CourseName"
Me.cboCourseNameID = Null
EnableControls
FilterDescriptionList
End Sub
Private Sub cboCourseTypeID_AfterUpdate()
' Set the Department combo box to be limited by the selected CourseType
Me.cboDepartmentID.RowSource = "SELECT tblCourseDept.DepartmentID, tblCourseDept.DepartmentName FROM tblCourseDept " & _
" WHERE CourseTypeID = " & Nz(Me.cboCourseTypeID) & _
" ORDER BY DepartmentName"
Me.cboDepartmentID = Null
EnableControls
FilterDescriptionList
End Sub
Private Sub cboDepartmentID_AfterUpdate()
' Set the Course No combo box to be limited by the selected Department
Me.cboCourseNoID.RowSource = "SELECT tblCourseNo.CourseNoID, tblCourseNo.CourseNo FROM tblCourseNo " & _
" WHERE DepartmentID = " & Nz(Me.cboDepartmentID) & _
" ORDER BY CourseNo"
Me.cboCourseNoID = Null
EnableControls
FilterDescriptionList
End Sub
Private Sub FilterDescriptionList()
Dim strRS As String
' Filter the list box appropriately based on the combo box selection(s)
strRS = "SELECT qryCourseDescList.UnitsAssigned, qryCourseDescList.Offered, qryCourseDescList.Prereqs FROM qryCourseDescList"
If Not IsNull(Me.cboCourseNameID) Then
strRS = strRS & " WHERE CourseNameID = " & Me.cboCourseNameID
ElseIf Not IsNull(Me.cboCourseNoID) Then
strRS = strRS & " WHERE CourseNoID = " & Me.cboCourseNoID
ElseIf Not IsNull(Me.cboDepartmentID) Then
strRS = strRS & " WHERE DepartmentID = " & Me.cboDepartmentID
ElseIf Not IsNull(Me.cboCourseTypeID) Then
strRS = strRS & " WHERE CourseTypeID = " & Me.cboCourseTypeID
End If
strRS = strRS & " ORDER BY qryCourseDescList.Offered;"
Me.lstDescriptionID.RowSource = strRS
Me.lstDescriptionID.Requery
End Sub
Private Sub EnableControls()
' Clear the combo boxes
If IsNull(Me.cboCourseTypeID) Then
Me.cboDepartmentID = Null
End If
If IsNull(Me.cboDepartmentID) Then
Me.cboCourseNoID = Null
End If
If IsNull(Me.cboCourseNoID) Then
Me.cboCourseNameID = Null
End If
' Enable or disable combo boxes based on whether the combo box preceeding it has a value.
Me.cboDepartmentID.Enabled = (Not IsNull(Me.cboCourseTypeID))
Me.cboCourseNoID.Enabled = (Not IsNull(Me.cboDepartmentID))
Me.cboCourseNameID.Enabled = (Not IsNull(Me.cboCourseNoID))
End Sub
Private Sub cboTransfer_AfterUpdate()
'Hide the tranfser from field unles status is transferred
If Me.cboTransfer = "Yes" Then
Me.cboTransferedFrom.Visible = True
Else
Me.cboTransferedFrom.Visible = False
End If
End Sub
Private Sub Form_Current()
'Hide the tranfser from field unles status is transferred
If Me.cboTransfer = "Yes" Then
Me.cboTransferedFrom.Visible = True
Else
Me.cboTransferedFrom.Visible = False
End If
End Sub
Private Sub Form_Load()
' When the form loads, enable/disable the combo boxes. Combo boxes are only enabled if the preceeding combo box has a value.
EnableControls
' Show all courses in the list until filters are selected from the combo boxes.
FilterDescriptionList
End Sub
setup (though not other fields on form as they are working and saving) Also every time I attempt to add a new record, when you change the selection in the cascading combo boxes it changes the information for the first record to match the second record (And it will only allow me to enter 2 records when I need 20+ records) the save and save & close buttons
"Save"
RunMenuCommand
Command Save Record
RefreshRecord
"Save and Close"
If [Form].[Dirty]
Save Record
end if
Close Window [,,Prompt]
Submacro ErrorHandler
MessageBox (=[MacroError].[Description],Yes,None,)
End Submacro
the code for the cascading combo is:
Option Compare Database
Option Explicit
Private Sub cboCourseNameID_AfterUpdate()
' Filter the list of courses based on the selected information.
FilterDescriptionList
End Sub
Private Sub cboCourseNoID_AfterUpdate()
' Set the Course Name combo box to be limited by the selected Course No
Me.cboCourseNameID.RowSource = "SELECT tblCourseName.CourseNameID, tblCourseName.CourseName FROM tblCourseName " & _
" WHERE CourseNoID = " & Nz(Me.cboCourseNoID) & _
" ORDER BY CourseName"
Me.cboCourseNameID = Null
EnableControls
FilterDescriptionList
End Sub
Private Sub cboCourseTypeID_AfterUpdate()
' Set the Department combo box to be limited by the selected CourseType
Me.cboDepartmentID.RowSource = "SELECT tblCourseDept.DepartmentID, tblCourseDept.DepartmentName FROM tblCourseDept " & _
" WHERE CourseTypeID = " & Nz(Me.cboCourseTypeID) & _
" ORDER BY DepartmentName"
Me.cboDepartmentID = Null
EnableControls
FilterDescriptionList
End Sub
Private Sub cboDepartmentID_AfterUpdate()
' Set the Course No combo box to be limited by the selected Department
Me.cboCourseNoID.RowSource = "SELECT tblCourseNo.CourseNoID, tblCourseNo.CourseNo FROM tblCourseNo " & _
" WHERE DepartmentID = " & Nz(Me.cboDepartmentID) & _
" ORDER BY CourseNo"
Me.cboCourseNoID = Null
EnableControls
FilterDescriptionList
End Sub
Private Sub FilterDescriptionList()
Dim strRS As String
' Filter the list box appropriately based on the combo box selection(s)
strRS = "SELECT qryCourseDescList.UnitsAssigned, qryCourseDescList.Offered, qryCourseDescList.Prereqs FROM qryCourseDescList"
If Not IsNull(Me.cboCourseNameID) Then
strRS = strRS & " WHERE CourseNameID = " & Me.cboCourseNameID
ElseIf Not IsNull(Me.cboCourseNoID) Then
strRS = strRS & " WHERE CourseNoID = " & Me.cboCourseNoID
ElseIf Not IsNull(Me.cboDepartmentID) Then
strRS = strRS & " WHERE DepartmentID = " & Me.cboDepartmentID
ElseIf Not IsNull(Me.cboCourseTypeID) Then
strRS = strRS & " WHERE CourseTypeID = " & Me.cboCourseTypeID
End If
strRS = strRS & " ORDER BY qryCourseDescList.Offered;"
Me.lstDescriptionID.RowSource = strRS
Me.lstDescriptionID.Requery
End Sub
Private Sub EnableControls()
' Clear the combo boxes
If IsNull(Me.cboCourseTypeID) Then
Me.cboDepartmentID = Null
End If
If IsNull(Me.cboDepartmentID) Then
Me.cboCourseNoID = Null
End If
If IsNull(Me.cboCourseNoID) Then
Me.cboCourseNameID = Null
End If
' Enable or disable combo boxes based on whether the combo box preceeding it has a value.
Me.cboDepartmentID.Enabled = (Not IsNull(Me.cboCourseTypeID))
Me.cboCourseNoID.Enabled = (Not IsNull(Me.cboDepartmentID))
Me.cboCourseNameID.Enabled = (Not IsNull(Me.cboCourseNoID))
End Sub
Private Sub cboTransfer_AfterUpdate()
'Hide the tranfser from field unles status is transferred
If Me.cboTransfer = "Yes" Then
Me.cboTransferedFrom.Visible = True
Else
Me.cboTransferedFrom.Visible = False
End If
End Sub
Private Sub Form_Current()
'Hide the tranfser from field unles status is transferred
If Me.cboTransfer = "Yes" Then
Me.cboTransferedFrom.Visible = True
Else
Me.cboTransferedFrom.Visible = False
End If
End Sub
Private Sub Form_Load()
' When the form loads, enable/disable the combo boxes. Combo boxes are only enabled if the preceeding combo box has a value.
EnableControls
' Show all courses in the list until filters are selected from the combo boxes.
FilterDescriptionList
End Sub
Last edited: