Locating a record on a subform on a tabbed form

T

Tony

Hi,

How do I go to an exact record FROM a search form TO a
subform that is located on a tabbed from on my main form.
Can someone help?

Thanks
Tony

Private Sub lstResult_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMainForm"
stLinkCriteria = "[EventID] = " & Me![EventID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"
End Sub
 
J

Jonathan Parminter

-----Original Message-----
Hi,

How do I go to an exact record FROM a search form TO a
subform that is located on a tabbed from on my main form.
Can someone help?

Thanks
Tony

Private Sub lstResult_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMainForm"
stLinkCriteria = "[EventID] = " & Me![EventID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"
End Sub


.

Hi Tony,
the following assumes that you are using the following
names...
Main form: frmMainForm
Tab control: tabCtl1
Subform control: sfrmSubForm

Also assumed is that the tab page that the subform
control is on is the second page.

Use the following as an example...

Private Sub lstResult_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim frm as Form
Dim ctl as Control

stDocName = "frmMainForm"

' use to go to a main form record
stLinkCriteria = "[EventID] = " & Me![EventID]

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"

set frm=Forms(stDocName)!sfrmSubForm.form
set ctl=Forms(stDocName)!tabCtl1

' switch to second page of tab control
tabCtl1.value=1

' criteria for subform record
stLinkCriteria = "[RecordID] = " & Me![RecordID]
frm.recordsetclone.findfirst stLinkCriteria

if not frm.recordsetclone.nomatch then
frm.bookmark = frm.recordsetclone.bookmark
end if

End Sub

Luck
Jonathan
 
T

Tony

Hi Johnathan,

Thanks for your reply - almost there!
It's coming up with a Variable not defined error on the
line TabCtl0.Value = 0
I've tried fiddling with it but no luck.
Any suggestions?

Tony
Here's what the code look like now

Dim stDocName As String
Dim stLinkCriteria As String
Dim frm As Form
Dim ctl As Control

stDocName = "frmMainForm"

' use to go to a main form record
stLinkCriteria = "[EventID] = " & Me![EventID]

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"

Set frm = Forms(stDocName)!SubFormCalendarOfEvents.Form
Set ctl = Forms(stDocName)!TabCtl0

' switch to second page of tab control
TabCtl0.Value = 0

' criteria for subform record
stLinkCriteria = "[EventID] = " & Me![EventID]
frm.RecordsetClone.FindFirst stLinkCriteria

If Not frm.RecordsetClone.NoMatch Then
frm.Bookmark = frm.RecordsetClone.Bookmark
End If


-----Original Message-----
-----Original Message-----
Hi,

How do I go to an exact record FROM a search form TO a
subform that is located on a tabbed from on my main form.
Can someone help?

Thanks
Tony

Private Sub lstResult_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMainForm"
stLinkCriteria = "[EventID] = " & Me![EventID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"
End Sub


.

Hi Tony,
the following assumes that you are using the following
names...
Main form: frmMainForm
Tab control: tabCtl1
Subform control: sfrmSubForm

Also assumed is that the tab page that the subform
control is on is the second page.

Use the following as an example...

Private Sub lstResult_DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim frm as Form
Dim ctl as Control

stDocName = "frmMainForm"

' use to go to a main form record
stLinkCriteria = "[EventID] = " & Me![EventID]

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmSearch"

set frm=Forms(stDocName)!sfrmSubForm.form
set ctl=Forms(stDocName)!tabCtl1

' switch to second page of tab control
tabCtl1.value=1

' criteria for subform record
stLinkCriteria = "[RecordID] = " & Me![RecordID]
frm.recordsetclone.findfirst stLinkCriteria

if not frm.recordsetclone.nomatch then
frm.bookmark = frm.recordsetclone.bookmark
end if

End Sub

Luck
Jonathan
.
 

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