Use pop up to go to record on subform

  • Thread starter butboris via AccessMonster.com
  • Start date
B

butboris via AccessMonster.com

Hi all

I have a pop up form called "Student Finder" which is bound to a query which
displays information of my subform.

At this stage, my query and pop up displays the information I seek and thanks
to previous posts I was able to us the "on click" event on the pop up ID
field to take me to the record but it only goes to the first record of the
subform not the record on subform i chose.
I want the the on click event of the pop up to take me to the parent record
and then to navigate subform record.

The parent form is called "CourseLocationDetails" and the subform is called
"Student Details"
The tables have a one to many relationship set up i.e. One
CourseLocationDetails can have many student details.

My code so far which is on the pop up:

Private Sub ID_Click()
Dim strf As String
strf = "CourseLocationDetails"
DoCmd.OpenForm strf
Forms(strf).Recordset.FindFirst "ID = " & Str(Nz([Forms]![StudentFinder].[ID])
)
DoCmd.Close acForm, "StudentFinder"
End Sub

I have searched an have not as yet found how to achieve this.
Thanks for any help on this!
 
T

tina

I want the the on click event of the pop up to take me to the parent
record
and then to navigate subform record.

does the query underlying the "Student Finder" form include the primary key
field of the subform records? if so, try doing a second find in the code,
immediately after the first find, as

Private Sub ID_Click()

Dim strf As String
strf = "CourseLocationDetails"
DoCmd.OpenForm strf
With Forms(strf)
.Recordset.FindFirst "ID = " _
& Str(Nz([Forms]![StudentFinder].[ID]))
!SubformControlName.Form.Recordset.FindFirst "pkfieldname = " _
& Me!pkfieldname
End With
DoCmd.Close acForm, "StudentFinder"
End Sub

replace "fkfieldname" with the correct name of the field, of course. and
replace SubformControlName with the correct name of the subform control
*within the mainform*.

hth


butboris via AccessMonster.com said:
Hi all

I have a pop up form called "Student Finder" which is bound to a query which
displays information of my subform.

At this stage, my query and pop up displays the information I seek and thanks
to previous posts I was able to us the "on click" event on the pop up ID
field to take me to the record but it only goes to the first record of the
subform not the record on subform i chose.
I want the the on click event of the pop up to take me to the parent record
and then to navigate subform record.

The parent form is called "CourseLocationDetails" and the subform is called
"Student Details"
The tables have a one to many relationship set up i.e. One
CourseLocationDetails can have many student details.

My code so far which is on the pop up:

Private Sub ID_Click()
Dim strf As String
strf = "CourseLocationDetails"
DoCmd.OpenForm strf
Forms(strf).Recordset.FindFirst "ID = " & Str(Nz([Forms]![StudentFinder].[ID])
)
DoCmd.Close acForm, "StudentFinder"
End Sub

I have searched an have not as yet found how to achieve this.
Thanks for any help on this!
 
B

butboris via AccessMonster.com

Hi tina,

Worked perfectly as you described !

Thank you so very much, I certainly do appreciate all help that you and
others on this website provide.
I want the the on click event of the pop up to take me to the parent record
and then to navigate subform record.

does the query underlying the "Student Finder" form include the primary key
field of the subform records? if so, try doing a second find in the code,
immediately after the first find, as

Private Sub ID_Click()

Dim strf As String
strf = "CourseLocationDetails"
DoCmd.OpenForm strf
With Forms(strf)
.Recordset.FindFirst "ID = " _
& Str(Nz([Forms]![StudentFinder].[ID]))
!SubformControlName.Form.Recordset.FindFirst "pkfieldname = " _
& Me!pkfieldname
End With
DoCmd.Close acForm, "StudentFinder"
End Sub

replace "fkfieldname" with the correct name of the field, of course. and
replace SubformControlName with the correct name of the subform control
*within the mainform*.

hth
[quoted text clipped - 26 lines]
I have searched an have not as yet found how to achieve this.
Thanks for any help on this!
 
T

tina

you're very welcome :)


butboris via AccessMonster.com said:
Hi tina,

Worked perfectly as you described !

Thank you so very much, I certainly do appreciate all help that you and
others on this website provide.
I want the the on click event of the pop up to take me to the parent record
and then to navigate subform record.

does the query underlying the "Student Finder" form include the primary key
field of the subform records? if so, try doing a second find in the code,
immediately after the first find, as

Private Sub ID_Click()

Dim strf As String
strf = "CourseLocationDetails"
DoCmd.OpenForm strf
With Forms(strf)
.Recordset.FindFirst "ID = " _
& Str(Nz([Forms]![StudentFinder].[ID]))
!SubformControlName.Form.Recordset.FindFirst "pkfieldname = " _
& Me!pkfieldname
End With
DoCmd.Close acForm, "StudentFinder"
End Sub

replace "fkfieldname" with the correct name of the field, of course. and
replace SubformControlName with the correct name of the subform control
*within the mainform*.

hth
[quoted text clipped - 26 lines]
I have searched an have not as yet found how to achieve this.
Thanks for any help on this!
 

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