Changing How Combobox Functions Based on Form's Editing Mode? ("Add" vs. "Edit")
Hey all,
I'm not sure if this is a feasible possibility, but is it possible to change the value of a control on a form (i.e., a combobox) depending on what mode a form is opened to?
The combobox that I have right now is bound to a field in a table, called "FormID". I'd ideally like to have a combobox either:
A) be able to add a FormID into its bound table only if the form is open in "Add" mode.
OR
B) be able to search for a particular record, by FormID, only if the form is open in "Edit" mode.
I saw this code on entries related to using a combo box to search for a particular ID - but it appears that for this code to work, the combo box MUST be unbound:
Meanwhile, I saw this code in the Microsoft Access EditMode Property Help, which appears to change how the edit mode operates under different editing states:
Thank you in advance for your feedback!
Hey all,
I'm not sure if this is a feasible possibility, but is it possible to change the value of a control on a form (i.e., a combobox) depending on what mode a form is opened to?
The combobox that I have right now is bound to a field in a table, called "FormID". I'd ideally like to have a combobox either:
A) be able to add a FormID into its bound table only if the form is open in "Add" mode.
OR
B) be able to search for a particular record, by FormID, only if the form is open in "Edit" mode.
I saw this code on entries related to using a combo box to search for a particular ID - but it appears that for this code to work, the combo box MUST be unbound:
Code:
On Error GoTo myError Dim rst As DAO.Recordset Set rst = Me.RecordsetClone rst.FindFirst "ID = " & Me!ctlSearch Me.Bookmark = rst.Bookmark leave: Me!ctlSearch = Null If Not rst Is Nothing Then Set rst = Nothing Exit Sub myError: MsgBox "Record Not Found" Resume leave
Meanwhile, I saw this code in the Microsoft Access EditMode Property Help, which appears to change how the edit mode operates under different editing states:
Code:
Sub EditModeX() Dim dbsNorthwind As Database Dim rstEmployees As Recordset Set dbsNorthwind = OpenDatabase("Northwind.mdb") Set rstEmployees = _ dbsNorthwind.OpenRecordset("Employees", _ dbOpenDynaset) ' Show the EditMode property under different editing ' states. With rstEmployees EditModeOutput "Before any Edit or AddNew:", .EditMode .Edit EditModeOutput "After Edit:", .EditMode .Update EditModeOutput "After Update:", .EditMode .AddNew EditModeOutput "After AddNew:", .EditMode .CancelUpdate EditModeOutput "After CancelUpdate:", .EditMode .Close End With dbsNorthwind.Close End Sub Function EditModeOutput(strTemp As String, _ intEditMode As Integer) ' Print report based on the value of the EditMode ' property. Debug.Print strTemp Debug.Print " EditMode = "; Select Case intEditMode Case dbEditNone Debug.Print "dbEditNone" Case dbEditInProgress Debug.Print "dbEditInProgress" Case dbEditAdd Debug.Print "dbEditAdd" End Select End Function
Thank you in advance for your feedback!