I have a form called fSearchforCompany with two unbound fields. After
selecting a field from lstQuickSearch (list box) and tabbing to txtSearchBox
to enter data, the correct form should open with the text from txtSearchBox
entered into the designated field. But, first the code should check for null,
and if Null, open the correct form.
The problems are the code is not doing anything on Null and when there is
data it is not selecting the data.
The two fields are:
.....lstQuickSearch
.....ControlSource is empty
.....Row Source = 1;"Company ID";2;"Company Name";3;"Date of Event";4;"Event Type"
.....Row Type = Value List[/INDENT]
.....txtSearchBox
.....Control Source is empty
After Update Event code is listed below:
selecting a field from lstQuickSearch (list box) and tabbing to txtSearchBox
to enter data, the correct form should open with the text from txtSearchBox
entered into the designated field. But, first the code should check for null,
and if Null, open the correct form.
The problems are the code is not doing anything on Null and when there is
data it is not selecting the data.
The two fields are:
.....lstQuickSearch
.....ControlSource is empty
.....Row Source = 1;"Company ID";2;"Company Name";3;"Date of Event";4;"Event Type"
.....Row Type = Value List[/INDENT]
.....txtSearchBox
.....Control Source is empty
After Update Event code is listed below:
Private Sub txtSearchBox_AfterUpdate()
On Error GoTo ErrorHandler
CleanUpAndExit:
Exit Sub
ErrorHandler:
Call MsgBox("An error was encountered" & vbCrLf & vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number, , "Error")
Resume CleanUpAndExit
End Sub
Thanks for any help!On Error GoTo ErrorHandler
Select Case Me.lstQuickSearch.Value
End Select
Case 1:
Case ElseIf IsNull(txtSearchBox) Then
Case 2:DoCmd.OpenForm ("[frmListforCompanyID")
DoCmd.GoToControl ("cboSearchBox")
ElseDoCmd.GoToControl ("cboSearchBox")
DoCmd.OpenForm ("frmListforCompanyID")
DoCmd.GoToControl ("cboSearchBox")
Forms!frmListforCompanyID!cboSearchBox.ControlSource =
txtSearchBox
End IfDoCmd.GoToControl ("cboSearchBox")
Forms!frmListforCompanyID!cboSearchBox.ControlSource =
txtSearchBox
If IsNull(txtSearchBox) Then
Case 2:DoCmd.OpenForm ("frmListforCompanyName")
DoCmd.GoToControl ("cboSearchBox")
ElseDoCmd.GoToControl ("cboSearchBox")
DoCmd.OpenForm ("frmListforCompanyName")
DoCmd.GoToControl ("cboSearchBox")
Forms!frmListforCompanyName!cboSearchBox.ControlSource =
txtSearchBox
End IfDoCmd.GoToControl ("cboSearchBox")
Forms!frmListforCompanyName!cboSearchBox.ControlSource =
txtSearchBox
If IsNull(txtSearchBox) Then
DoCmd.OpenForm ("fdlgEventDetail")
DoCmd.GoToControl ("txtEventDate")
ElseDoCmd.GoToControl ("txtEventDate")
DoCmd.OpenForm ("fdlgEventDetail")
DoCmd.GoToControl ("txtEventDate")
Forms!fdlgEventDetail!txtEventDate.ControlSource =
txtSearchBox
End IfDoCmd.GoToControl ("txtEventDate")
Forms!fdlgEventDetail!txtEventDate.ControlSource =
txtSearchBox
MsgBox "Invalid selection", vbExclamation
Exit SubEnd Select
CleanUpAndExit:
Exit Sub
ErrorHandler:
Call MsgBox("An error was encountered" & vbCrLf & vbCrLf & _
"Description: " & Err.Description & vbCrLf & _
"Error Number: " & Err.Number, , "Error")
Resume CleanUpAndExit
End Sub