F
Fred Boer
Hello:
I am having a problem with the "dropped-down" state of a combobox. It occurs
in a "not in list" situation. Code is reproduced below:
I found a possible solution by googling, which involves moving the focus
from the combobox, and then moving the focus back to the combobox (see
"Attempted solution here:" in code). It doesn't work. The focus ends up back
in the combobox, but the combobox is still "dropped down". I have tried
setting break points and the code *does* fire. I have also tried remarking
out the line which would set the focus back to the combobox. When I do this
the focus is correctly set on the command button.
Thanks!
Fred Boer
Private Sub cboAuthor_NotInList(NewData As String, Response As Integer)
On Error GoTo Errorhandler
Dim mbrResponse As VbMsgBoxResult
Dim strMsg As String
Dim db As Database, ssql As String
strMsg = NewData & " isn't an existing author. " & "Add a new author?"
mbrResponse = MsgBox(strMsg, vbYesNo + vbQuestion, "Invalid Author")
Select Case mbrResponse
Case vbYes
DoCmd.OpenForm "Frm_InsertAuthor", OpenArgs:=NewData,
DataMode:=acFormAdd, Windowmode:=acDialog
' Stop here and wait until the form goes away.
If ISLOADED("Frm_InsertAuthor") Then
Response = acDataErrAdded
DoCmd.Close acForm, "Frm_InsertAuthor"
Else
Response = acDataErrContinue
End If
Case vbNo
Response = acDataErrContinue
End Select
'Attempted solution here:
'Shift focus from combobox to force close of dropdown list, then back
Forms!Frm_LibraryDataEdit!cmdGoFirst.SetFocus
Forms!Frm_LibraryDataEdit!cboAuthor.SetFocus
ExitPoint:
Exit Sub
Errorhandler:
fncWRMSErrMsg Err.Number, Err.Description
Resume ExitPoint
End Sub
I am having a problem with the "dropped-down" state of a combobox. It occurs
in a "not in list" situation. Code is reproduced below:
I found a possible solution by googling, which involves moving the focus
from the combobox, and then moving the focus back to the combobox (see
"Attempted solution here:" in code). It doesn't work. The focus ends up back
in the combobox, but the combobox is still "dropped down". I have tried
setting break points and the code *does* fire. I have also tried remarking
out the line which would set the focus back to the combobox. When I do this
the focus is correctly set on the command button.
Thanks!
Fred Boer
Private Sub cboAuthor_NotInList(NewData As String, Response As Integer)
On Error GoTo Errorhandler
Dim mbrResponse As VbMsgBoxResult
Dim strMsg As String
Dim db As Database, ssql As String
strMsg = NewData & " isn't an existing author. " & "Add a new author?"
mbrResponse = MsgBox(strMsg, vbYesNo + vbQuestion, "Invalid Author")
Select Case mbrResponse
Case vbYes
DoCmd.OpenForm "Frm_InsertAuthor", OpenArgs:=NewData,
DataMode:=acFormAdd, Windowmode:=acDialog
' Stop here and wait until the form goes away.
If ISLOADED("Frm_InsertAuthor") Then
Response = acDataErrAdded
DoCmd.Close acForm, "Frm_InsertAuthor"
Else
Response = acDataErrContinue
End If
Case vbNo
Response = acDataErrContinue
End Select
'Attempted solution here:
'Shift focus from combobox to force close of dropdown list, then back
Forms!Frm_LibraryDataEdit!cmdGoFirst.SetFocus
Forms!Frm_LibraryDataEdit!cboAuthor.SetFocus
ExitPoint:
Exit Sub
Errorhandler:
fncWRMSErrMsg Err.Number, Err.Description
Resume ExitPoint
End Sub