I am trying to open a search results form based on the input from a
prompt form. I am using the following code:
--- Begin Code ---
Private Sub btnSearch_Click ()
'Dim Variable and assign data
Dim srce As String, fstnme As String, lstnme As String, bidnum As String
srce = Me.Source_Contr ol
If Not IsNull(Me.Text1 8) Then
lstnme = Me.Text18
'Open Results Form
DoCmd.OpenForm "frmSearch_Resu lts", , , "[last_name] = '" & lstnme & "'"
'Assign Source Control Data
Forms![frmSearch_Resul ts].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Se arch", acSaveNo
Exit Sub
ElseIf Not IsNull(Me.Text1 6) Then
fstnme = Me.Text16
'Open Results Form
DoCmd.OpenForm "frmSearch_Resu lts", , , "[first_name] = '" & fstnme &"'"
'Assign Source Control Data
Forms![frmSearch_Resul ts].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Se arch", acSaveNo
Exit Sub
ElseIf Not IsNull(Me.Text2 0) Then
bidnum = Me.Text20
'Open Results Form
DoCmd.OpenForm "frmSearch_Resu lts", , , "[last_bidder_num ber] = " &
bidnum 'Assign Source Control Data
Forms![frmSearch_Resul ts].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Se arch", acSaveNo
Exit Sub
End If
End Sub
--- End Code ---
Sorry for the word wrapping. All the lines are single lines no wraping
in the program.
The primary search field is the last name. This is why it is checked
first. The problem is when I open the search results form, it opens with
the previous query results not the current request, unless I set a break
point and the code pauses and I then hit the 'RUN' key (F5) to contine
the code execution.
How can I get the form to open with the correct results without stopping
or pausing the code run?
I am using MS-Access 2003 as a front end to a MS-SQL MSDE backend. This
is an Access Project.
Thansk for any help!!
Mike Charney
prompt form. I am using the following code:
--- Begin Code ---
Private Sub btnSearch_Click ()
'Dim Variable and assign data
Dim srce As String, fstnme As String, lstnme As String, bidnum As String
srce = Me.Source_Contr ol
If Not IsNull(Me.Text1 8) Then
lstnme = Me.Text18
'Open Results Form
DoCmd.OpenForm "frmSearch_Resu lts", , , "[last_name] = '" & lstnme & "'"
'Assign Source Control Data
Forms![frmSearch_Resul ts].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Se arch", acSaveNo
Exit Sub
ElseIf Not IsNull(Me.Text1 6) Then
fstnme = Me.Text16
'Open Results Form
DoCmd.OpenForm "frmSearch_Resu lts", , , "[first_name] = '" & fstnme &"'"
'Assign Source Control Data
Forms![frmSearch_Resul ts].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Se arch", acSaveNo
Exit Sub
ElseIf Not IsNull(Me.Text2 0) Then
bidnum = Me.Text20
'Open Results Form
DoCmd.OpenForm "frmSearch_Resu lts", , , "[last_bidder_num ber] = " &
bidnum 'Assign Source Control Data
Forms![frmSearch_Resul ts].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Se arch", acSaveNo
Exit Sub
End If
End Sub
--- End Code ---
Sorry for the word wrapping. All the lines are single lines no wraping
in the program.
The primary search field is the last name. This is why it is checked
first. The problem is when I open the search results form, it opens with
the previous query results not the current request, unless I set a break
point and the code pauses and I then hit the 'RUN' key (F5) to contine
the code execution.
How can I get the form to open with the correct results without stopping
or pausing the code run?
I am using MS-Access 2003 as a front end to a MS-SQL MSDE backend. This
is an Access Project.
Thansk for any help!!
Mike Charney
Comment