Hi, I'm a newbie in Access.
I have 3 bound comboboxes and other bound textboxes and radio buttons on my form. When I select an item in a combobox and close the form it overwrites the previous record in the database. This is NOT a desired behaviour. Here's an example when I select Region 2 and close the form.
BEFORE AFTER
cboRegionName cboRegionName
Region 1 Region 2
Region 2 Region 2
Region 3 Region 3
You may ask why I don't make the comboboxes or the entire form unbound and use Recordset.Clone with a bookmark. Reason is I want to use the same form to enter new records when clicking the >* button at the bottom...ye know what I mean? Here's how I load my form.
Private Sub Form_Load()
'Combobox 1
Me.cboRegionName.RowSource = "SELECT DISTINCT sqlFormRS.RegionID, sqlFormRS.RegionName " & _
" FROM sqlFormRS " & _
" ORDER BY 2;"
Me.txtRegionID = Me.cboRegionName.Column(0)
'Combobox 2
Me.cboPrisonName.RowSource = "SELECT DISTINCT PrisonID, PrisonName " & _
" FROM sqlFormRS " & _
" WHERE sqlFormRS.RegionID = " & Me.txtRegionID & _
" ORDER BY 2;"
'Combobox 3
Me.cboFacNo.RowSource = "SELECT FacilityID, FacNo" & _
" FROM sqlFormRS " & _
" WHERE PrisonID = " & Me.txtPrisonID & _
" ORDER BY 2;"
Me.txtFacID = Me.cboFacNo.Column(0)
'Text fields
Me.txtInspectorName = DLookup("[InspectorName]", "sqlFormRS", "[FacilityID] = " & Me.txtFacID)
....
End Sub
So what can I do to prevent the comboboxes to autosave on a selection? Thanks for your help!
I have 3 bound comboboxes and other bound textboxes and radio buttons on my form. When I select an item in a combobox and close the form it overwrites the previous record in the database. This is NOT a desired behaviour. Here's an example when I select Region 2 and close the form.
BEFORE AFTER
cboRegionName cboRegionName
Region 1 Region 2
Region 2 Region 2
Region 3 Region 3
You may ask why I don't make the comboboxes or the entire form unbound and use Recordset.Clone with a bookmark. Reason is I want to use the same form to enter new records when clicking the >* button at the bottom...ye know what I mean? Here's how I load my form.
Private Sub Form_Load()
'Combobox 1
Me.cboRegionName.RowSource = "SELECT DISTINCT sqlFormRS.RegionID, sqlFormRS.RegionName " & _
" FROM sqlFormRS " & _
" ORDER BY 2;"
Me.txtRegionID = Me.cboRegionName.Column(0)
'Combobox 2
Me.cboPrisonName.RowSource = "SELECT DISTINCT PrisonID, PrisonName " & _
" FROM sqlFormRS " & _
" WHERE sqlFormRS.RegionID = " & Me.txtRegionID & _
" ORDER BY 2;"
'Combobox 3
Me.cboFacNo.RowSource = "SELECT FacilityID, FacNo" & _
" FROM sqlFormRS " & _
" WHERE PrisonID = " & Me.txtPrisonID & _
" ORDER BY 2;"
Me.txtFacID = Me.cboFacNo.Column(0)
'Text fields
Me.txtInspectorName = DLookup("[InspectorName]", "sqlFormRS", "[FacilityID] = " & Me.txtFacID)
....
End Sub
So what can I do to prevent the comboboxes to autosave on a selection? Thanks for your help!