Open form to specific record from button on continuous form

S

sml

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
 
J

Jeanette Cunningham

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
 
B

BruceM via AccessMonster.com

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.


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
 
S

sml

Worked like a charm. Thanks!

Jeanette Cunningham said:
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 said:
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


.
 
M

mans

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_Clic
Dim stDocName As Strin
Dim stLinkCriteria As Strin
stDocName = "frmMoreInfo

End Sub
 

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