Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo not in list

Status
Not open for further replies.

Domino2

Technical User
Jun 8, 2008
475
GB
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
 
I don't understand too well from the description. Also it will be helpful if you provide the error message. I think I know just which error it is, but if I am wrong then we're in for a big waste of time.

I would observe that NotOnList has the purpose of adding to a list, so giving the entry a probationary status may be difficult.

[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]​
 
Many thanks. At present the code works after adding a new item, but after putting in the value into Me.PF, the program returns focus to the combo which has now had its textbox cleared. If I then press return, it exits happily and sets focus to a new control. However if in the code I try and make it setfocus to another control Me.Dummy, it errors.

Me.PF = UCase(NewData) ' Just put the users typed in name into a textbox
Me.Combo2.Undo
Response = False
Cancel = True
Me.Dummy.SetFocus

I get error 2110, cannot move focus to control Dummy.

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top