• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Problem with form

I have a form that opens so the user can add a record.  Here is the code from the onclick event of a command button on a previousy opened form:

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmFinGoodsTranx"
    DoCmd.OpenForm stDocName, acNormal, , "[Type] = 'FG'", acFormAdd, acWindowNormal

Then on this same form I have a combobox from whch the user can select an existing record.  When they select the record I want the record to display on the form but this is not working.

Here is the afterupdate event code:

Private Sub Combo60_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![Combo60], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

What am I doing wrong?
0
SteveL13
Asked:
SteveL13
  • 2
  • 2
1 Solution
 
mbizupCommented:
Since the form is already filtered, try unfiltering it first:


Private Sub Combo60_AfterUpdate()
    ' Find the record that matches the control.
    set me.filterOn = false
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[ID] = " & Str(Nz(Me![Combo60], 0))
    If Not rs.NoMatch Then
          Me.Bookmark = rs.Bookmark
    Else
           msgbox "record not found"
    end if
End Sub

0
 
danishaniCommented:
I am with mbizup, only one remark:
If the field [ID] is a Number type, change the following line;
  rs.FindFirst "[ID] = " & Nz(Me![Combo60], 0)

Make sure that the bound Column of the Combobox matches the [ID].

Hope this helps,
Daniel

0
 
SteveL13Author Commented:
Is not working.  First of all ID is a number field so I did change that one line.  I am getting an error:

Compile Error:  Invalid use of property.  And the in the code this line is highlighted...

Set Me.Filteron = False

???
0
 
danishaniCommented:
That must be :

Me.FilterOn = False

Hope that helps,
Daniel
0
 
SteveL13Author Commented:
Thank you!  Perfect.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now