DoCmd.OpenForm Problem



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_Control

If Not IsNull(Me.Text18) Then
lstnme = Me.Text18
'Open Results Form
DoCmd.OpenForm "frmSearch_Results", , , "[last_name] = '" & lstnme & "'"
'Assign Source Control Data
Forms![frmSearch_Results].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Search", acSaveNo
Exit Sub

ElseIf Not IsNull(Me.Text16) Then
fstnme = Me.Text16
'Open Results Form
DoCmd.OpenForm "frmSearch_Results", , , "[first_name] = '" & fstnme &"'"
'Assign Source Control Data
Forms![frmSearch_Results].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Search", acSaveNo
Exit Sub

ElseIf Not IsNull(Me.Text20) Then
bidnum = Me.Text20
'Open Results Form
DoCmd.OpenForm "frmSearch_Results", , , "[last_bidder_number] = " &
bidnum 'Assign Source Control Data
Forms![frmSearch_Results].[Source_Control] = srce
'Close Search Form
DoCmd.Close acForm, "frmCustomer_Search", 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
.



Relevant Pages

  • RE: Passing Values between forms
    ... comes from putting single quotes around the companyID field. ... new form that opens is frmScheduledActivities. ... Dim stLinkCriteria As String ... 1Private Sub Form_Load ...
    (microsoft.public.access.formscoding)
  • Re: Changing a Label in Code
    ... Sub SetTitle(strTitle As String) ... Then use code in the On Open event of the report>> to set its caption. ... Can I> somehow set the text box before the form opens, or perhaps I can> dynamically change the OnOpen event to the proper captions in code? ...
    (microsoft.public.access.reports)
  • Re: Passing Values between forms
    ... A subform, by itself... ... If I open (the sub could be just hidden) frmActivities for Smith & ... new form that opens is frmScheduledActivities. ... Dim stLinkCriteria As String ...
    (microsoft.public.access.formscoding)
  • RE: Tracking Log In and Log Out times of Users
    ... AuditLogger is a Sub, not a module. ... A Report module is the same, except it is specific to that report. ... A module cannot have a Sub or Function ... I have a start-up form that opens when the database opens. ...
    (microsoft.public.access.modulesdaovba)
  • Re: delete rows
    ... 'delete it in the close it will exist only for that workbook. ... Private Sub Workbook_Open ... but will be available to anyone who opens the ... Dim Rng As Range, Rng1 As Range ...
    (microsoft.public.excel.programming)