I am trying to do a form that requests data entry from a user before anything gets saved, ie they have a final save button.
On the form is a combo box where they can select an item or add an item. However I do not want the item added to the table at this stage, their typed in entry going into a variable.
The code below works okay, however returns the focus back to the combo after the operation of adding a new item. If I try to set the focus to another control it complains, and finally after messing about it says the record cannot be saved at this time. I had to put a variable PP in to allow a normal exit when the user presses return with no text entered in the combo textbox or no selection being made.
I have played around with the Response value etc but cannot sort the problem out. Any ideas, thanks
Private Sub Combo2_NotInList(NewData As String, Response As Integer)
PP = 1
Me.Label480.Visible = False
Me.Label485.Visible = False
Response = False
If MsgBox("The Folder " & UCase(NewData) & " does not exist. Create it?", vbYesNo) = vbYes Then
Me.PF = UCase(NewData) ' Just put the users typed in name into a textbox
Me.Combo2.Undo
Response = False
Cancel = True
Else
Me.PF = ""
Me.Combo2.Undo
Response = False
Cancel = True
End If
End Sub
Private Sub Combo2_Exit(Cancel As Integer)
If PP = 1 Then
PP = 0
Me.Dummy.SetFocus
Me.Combo2.Visible = False
Exit Sub
End If
If MsgBox("Do you want to cancel the new folder", vbYesNo) = vbYes Then
Cancel = True
' GOTO NEXT PART OF PROGRAM
Else
Cancel = True
Me.Combo2.SetFocus
End If
End Sub
On the form is a combo box where they can select an item or add an item. However I do not want the item added to the table at this stage, their typed in entry going into a variable.
The code below works okay, however returns the focus back to the combo after the operation of adding a new item. If I try to set the focus to another control it complains, and finally after messing about it says the record cannot be saved at this time. I had to put a variable PP in to allow a normal exit when the user presses return with no text entered in the combo textbox or no selection being made.
I have played around with the Response value etc but cannot sort the problem out. Any ideas, thanks
Private Sub Combo2_NotInList(NewData As String, Response As Integer)
PP = 1
Me.Label480.Visible = False
Me.Label485.Visible = False
Response = False
If MsgBox("The Folder " & UCase(NewData) & " does not exist. Create it?", vbYesNo) = vbYes Then
Me.PF = UCase(NewData) ' Just put the users typed in name into a textbox
Me.Combo2.Undo
Response = False
Cancel = True
Else
Me.PF = ""
Me.Combo2.Undo
Response = False
Cancel = True
End If
End Sub
Private Sub Combo2_Exit(Cancel As Integer)
If PP = 1 Then
PP = 0
Me.Dummy.SetFocus
Me.Combo2.Visible = False
Exit Sub
End If
If MsgBox("Do you want to cancel the new folder", vbYesNo) = vbYes Then
Cancel = True
' GOTO NEXT PART OF PROGRAM
Else
Cancel = True
Me.Combo2.SetFocus
End If
End Sub