Hi,
I have a subform created from joined table, with Combobox to link records to master form. Subform is designed without record selectors or navigation buttons, and is set to continuous form.
I have a code, where you can delete joined record for master form simply by deleting Combobox. When you delete Combobox text value, user just clicks on another field, and Msgbox for deleting records appears.
If user presses YES on Msgbox, record from joined table is deleted....
Now I want to enter same Combobox text value, which was in It before, IF User clicks NO in Msgbox !
Here's code (red colour is where things get wrong):
Code:
Private Sub Combo5_AfterUpdate()
Dim strMessage As String
Dim intResponse As Integer
Dim cmb As String
On Error GoTo ErrorHandler
' Display the custom dialog box.
strMessage = "Would you like to delete this record?"
cmb = Combo5.Text
' Check the response.
If IsNull(Combo5) Then
intResponse = MsgBox(strMessage, vbYesNo + _
vbQuestion, _
"Continue delete?")
End If
If intResponse = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
Cancel = True
Me.Combo5.Value = cmb
End If
Exit Sub
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & _
vbCrLf & Err.Description
End Sub
How can I store this Combobox value and then call It, in another Event or what ?
P.S.:
Check attached sample. Open tblName, and there you'll see subform. Delete "Kennedy" from combobox, and click on upper combobox. Msgbox will open - on YES it will delete record, on NO I want "Kennedy" back in Combobox.
Thanks for all help in advance !!