Filtering using a button

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?
 
A

Allen Browne

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.)
 
O

open a adobe file from a command button

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top