Filtering using a button

  • Thread starter Thread starter NotGood@All
  • Start date Start date
N

NotGood@All

I have a continuous form with a button on it. What I’m trying to do is when
the button is clicked open the record of the button that was clicked. I’ve
been playing, but the more I play the worse it gets. Would someone point me
in the right direction?
 
Here's an example of the code to put into the command button's Click Event
Procedure:

Private sub cmdGoto_Click()
Dim strWhere As String

If Me.Dirty Then Me.Dirty = False 'save any edits.
If Me.NewRecord Then
MsgBox "What record?"
Else
strWhere = "[ClientID] = " & Me.ClientID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If
End Sub

(This example assumes the primary key is a Number field named ClientID.)
 
That works nicely!! Thank you

Allen Browne said:
Here's an example of the code to put into the command button's Click Event
Procedure:

Private sub cmdGoto_Click()
Dim strWhere As String

If Me.Dirty Then Me.Dirty = False 'save any edits.
If Me.NewRecord Then
MsgBox "What record?"
Else
strWhere = "[ClientID] = " & Me.ClientID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If
End Sub

(This example assumes the primary key is a Number field named ClientID.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

NotGood@All said:
I have a continuous form with a button on it. What I’m trying to do is
when
the button is clicked open the record of the button that was clicked. I’ve
been playing, but the more I play the worse it gets. Would someone point
me in the right direction?
 
Back
Top