Subform with VBA in Navigation form (1 Viewer)

adple

New member
Local time
Today, 04:25
Joined
Mar 21, 2018
Messages
2
Hello everyone.
Im pretty newby in access and VBA. Two weeks ago i started create some base to collect data in lab.

But now im stuck in navigation form.

I have form called fmLabTest with continuous subform fmLabNagList that lists all the records of the fmLabTest record source.
I added a VBA code in the fmLabNagList to execute GoToRecord, showing the same record number in fmLabTest

Code:
Private Sub Form_Click()
Dim Reco As Integer
Reco = CurrentRecord
DoCmd.GoToRecord acDataForm, "fmLabTest", acGoTo, Reco
End Sub
It works, but when puted fmLabTest into navigation form navLab then problem started.
I tryed some examples from net but i can't figure how solve this problem:confused:.
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:25
Joined
May 7, 2009
Messages
19,237
Istead of using vba you can add Master/child link. On design view click on the subform. Make sure a boundary line is shown surrounding the sub. On its property window -> data, set the master to the field name if your mainform (pk) abd set the child link to the field on your subform (fk).
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:25
Joined
Feb 19, 2002
Messages
43,266
I would think twice about using a Navigation form. You can roll your own without too much trouble. I don't use them because I always seem to run into one of their limitations. The biggest issue is that the Navigation form loads your form into the subform control when you click on the tab. This is for the sake of efficiency but it also means that you can NEVER have two subforms active at the same time. This isn't a particularly common need but you don't want to get way down the development road and discover that it will be a problem for you.
 

adple

New member
Local time
Today, 04:25
Joined
Mar 21, 2018
Messages
2
Istead of using vba you can add Master/child link. On design view click on the subform. Make sure a boundary line is shown surrounding the sub. On its property window -> data, set the master to the field name if your mainform (pk) abd set the child link to the field on your subform (fk).

If i do like you wrote i see only one position on my subform fmLabNagList
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:25
Joined
May 7, 2009
Messages
19,237
so you only want to jump to that record in the subform.

private sub form_click()
dim rs as dao.recordset
set rs = me.frmLabTest.Form.Recordsetclone
rs.findfirst "id=" & me.id
if not rs.nomatch then _
me.frmLabTest.Form.Bookmark = rs.Bookmark
set rs=nothing
end sub
 

Users who are viewing this thread

Top Bottom