Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Findfirst method (2003)

    I have the following code:

    Private Sub Command28_Click()
    On Error GoTo Err_Command28_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmBadNewHabit"

    stLinkCriteria = "[BadHabit]=" & "'" & Me![BadHabit] & "'"
    DoCmd.OpenForm stDocName
    Me.Recordset.FindFirst stLinkCriteria
    If Me.Recordset.NoMatch Then
    MsgBox "Prob"
    Else
    MsgBox "OK" & vbCr & stLinkCriteria & vbCr & Me.BadHabit
    End If

    Exit_Command28_Click:
    Exit Sub

    Err_Command28_Click:
    MsgBox Err.Description
    Resume Exit_Command28_Click

    End Sub

    The find first method find the record as my msgbox return the right value but the active record when the form frmBadNewHabit pop up is always the first one and not the one return by the findfirst method. I can't figurate why.

    Marcel

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Findfirst method (2003)

    You apply the FindFirst method to Me.Recordset, i.e. to the recordset of the form that contains the command button Command28, not to the recordset of the form you open, i.e. frmBadNewHabit. Does it work if you use the following?

    ...
    Forms!frmBadNewHabit.Recordset.FindFirst stLinkCriteria
    If Forms!frmBadNewHabit.Recordset.NoMatch Then
    ...

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    195
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Findfirst method (2003)

    Hans,
    thank you, it works.
    Regards,
    Marcel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •