Manual Conversion of a Macro to VB

Mnewton911

New member
Local time
Today, 17:30
Joined
Sep 14, 2010
Messages
8
In a form that i have developed -
I have a combo box that i created with a wizard that you drop down and it lists the name of the record and goes to that record.

after looking at the after update in the properties - it shows an embedded macro .

the macro says Search for record and the condition is , , First, ="[Rule Acronym] = " & "'" & [Screen].[ActiveControl] & "'"

I wanted to create a VB module for the after update and add a couple steps.

What is the proper syntax for the Search For Record?

DoCmd.SearchForRecord , , First, ="[Rule Acronym] = " & "'" & [Screen].[ActiveControl] & "'"
 
In previous versions this is the code produced by the wizard:

Code:
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[FieldName] = " & str(Me![ComboName])
    Me.Bookmark = rs.Bookmark
 
You can convert your macro to VBA using the Convert Macros to Visual Basic menu option.

Here is the code I use to find a record in the after update event of a combo box...

Code:
    Me![txtAutonumber].SetFocus
    DoCmd.FindRecord Me![cboFindLastName], acEntire, True, acSearchAll, True, acCurrent, True
 

Users who are viewing this thread

Back
Top Bottom