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