From: sml on
I have a continous form with limited data and I would like to have a button
which then opens up a selected record in another form. I've placed the button
via the wizard and, while it opens the form, it doesn't open to the selected
record.

It it possible to have a button on a continous form which would then open
to a bookmarked record on another form? The wizard put this code, is it
possible to modify this?

Thanks.

Private Sub btnOpenForm_Click()
On Error GoTo btnOpenForm_Click_Err

DoCmd.OpenForm "frmName", acNormal, "", """[id]="" & [id]", , acNormal


btnOpenForm_Click_Exit:
Exit Sub

btnOpenForm_Click_Err:
MsgBox Error$
Resume btnOpenForm_Click_Exit

End Sub
From: Jeanette Cunningham on
Private Sub btnOpenForm_Click()
On Error GoTo btnOpenForm_Click_Err
Dim strWhere As String

'for a number type [ID]
strWhere = "[ID] = " & Me.[ID]

'for a text type [ID]
strWhere = "[ID] = """ & Me.[ID] & """"

DoCmd.OpenForm "frmName", , , strWhere


btnOpenForm_Click_Exit:
Exit Sub

btnOpenForm_Click_Err:
MsgBox Error$
Resume btnOpenForm_Click_Exit

End Sub

Note: replace [ID] with the name of the field that you are using to find the
matching record on the second form.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"sml" <sml(a)discussions.microsoft.com> wrote in message
news:BAE00FD3-6CC6-42A3-93F1-753376670C56(a)microsoft.com...
>I have a continous form with limited data and I would like to have a button
> which then opens up a selected record in another form. I've placed the
> button
> via the wizard and, while it opens the form, it doesn't open to the
> selected
> record.
>
> It it possible to have a button on a continous form which would then open
> to a bookmarked record on another form? The wizard put this code, is it
> possible to modify this?
>
> Thanks.
>
> Private Sub btnOpenForm_Click()
> On Error GoTo btnOpenForm_Click_Err
>
> DoCmd.OpenForm "frmName", acNormal, "", """[id]="" & [id]", , acNormal
>
>
> btnOpenForm_Click_Exit:
> Exit Sub
>
> btnOpenForm_Click_Err:
> MsgBox Error$
> Resume btnOpenForm_Click_Exit
>
> End Sub


From: BruceM via AccessMonster.com on
That doesn't look like the wizard code I generated in Access 2003 for a text
field. Assuming [id] is a text field, try something like:

DoCmd.OpenForm "frmName", acNormal, , "[id]= ' " & Me.[id] & " ' "

If there could be an apostrophe in [id]:

DoCmd.OpenForm "frmName", acNormal, , "[id]= " " " & Me.[id] & " " " "

Spaces between the quotes are for clarity. You do not need the spaces.
Access will probably get rid of them on its own.

If [id] is a number field:

DoCmd.OpenForm "frmName", acNormal, , "[id]= " & Me.[id]

You do not say where the command button is located. It will need to be on
the form itself, so it appears with every record on the continuous form. You
would click the button in the record you want to see.



sml wrote:
>I have a continous form with limited data and I would like to have a button
>which then opens up a selected record in another form. I've placed the button
>via the wizard and, while it opens the form, it doesn't open to the selected
>record.
>
>It it possible to have a button on a continous form which would then open
>to a bookmarked record on another form? The wizard put this code, is it
>possible to modify this?
>
>Thanks.
>
>Private Sub btnOpenForm_Click()
>On Error GoTo btnOpenForm_Click_Err
>
> DoCmd.OpenForm "frmName", acNormal, "", """[id]="" & [id]", , acNormal
>
>btnOpenForm_Click_Exit:
> Exit Sub
>
>btnOpenForm_Click_Err:
> MsgBox Error$
> Resume btnOpenForm_Click_Exit
>
>End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200912/1

From: sml on
Worked like a charm. Thanks!

"Jeanette Cunningham" wrote:

> Private Sub btnOpenForm_Click()
> On Error GoTo btnOpenForm_Click_Err
> Dim strWhere As String
>
> 'for a number type [ID]
> strWhere = "[ID] = " & Me.[ID]
>
> 'for a text type [ID]
> strWhere = "[ID] = """ & Me.[ID] & """"
>
> DoCmd.OpenForm "frmName", , , strWhere
>
>
> btnOpenForm_Click_Exit:
> Exit Sub
>
> btnOpenForm_Click_Err:
> MsgBox Error$
> Resume btnOpenForm_Click_Exit
>
> End Sub
>
> Note: replace [ID] with the name of the field that you are using to find the
> matching record on the second form.
>
>
>
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
> "sml" <sml(a)discussions.microsoft.com> wrote in message
> news:BAE00FD3-6CC6-42A3-93F1-753376670C56(a)microsoft.com...
> >I have a continous form with limited data and I would like to have a button
> > which then opens up a selected record in another form. I've placed the
> > button
> > via the wizard and, while it opens the form, it doesn't open to the
> > selected
> > record.
> >
> > It it possible to have a button on a continous form which would then open
> > to a bookmarked record on another form? The wizard put this code, is it
> > possible to modify this?
> >
> > Thanks.
> >
> > Private Sub btnOpenForm_Click()
> > On Error GoTo btnOpenForm_Click_Err
> >
> > DoCmd.OpenForm "frmName", acNormal, "", """[id]="" & [id]", , acNormal
> >
> >
> > btnOpenForm_Click_Exit:
> > Exit Sub
> >
> > btnOpenForm_Click_Err:
> > MsgBox Error$
> > Resume btnOpenForm_Click_Exit
> >
> > End Sub
>
>
> .
>
From: mans on


i would like to do the same with my button too but i cant seem to make it work. any ideas how im meant to change my code to do this also?

Private Sub Command48_Click()
On Error GoTo Err_Command48_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmMoreInfo"

End Sub

---
frmsrcurl: http://msgroups.net/microsoft.public.access.formscoding/Open-form-to-specific-record-from-button-on-continuous-form