RE: Locating a record on a subform on a tabbed form

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jonathan Parminter (anonymous_at_discussions.microsoft.com)
Date: 03/21/04


Date: Sat, 20 Mar 2004 18:07:46 -0800


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



Relevant Pages

  • Re: Is this a Sound Database Design? -- procedurenames must be unique in same module
    ... Since these are PRIVATE functions, it is ok to have another Private function with this name in ANOTHER module sheet. ... Created a form with a subform in it, named it TabSubform and then created a command button, named it SwitchTabs. ... Dummy is an unbound control -- really tiny because I use labels instead of command buttons and a label does not get the focus ... Dim mCurrentTab As Integer, i As Integer, mBoo As Boolean ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Is this a Sound Database Design? -- code: SwitchTabs
    ... The "command buttons" (put in quotes because I actually used label ... Dummy is an unbound control -- really tiny because I use labels instead ... Sometimes, the subforms do not have linking fields, like a lookup subform ... Dim mCurrentTab As Integer, i As Integer, mBoo As Boolean ...
    (microsoft.public.access.tablesdbdesign)
  • Subform RecordsetClone No Current Record error
    ... of rows all displayed in an Access 2000 subform. ... The "after update" event of the form control ... Dim bCategoryValOpposite As Boolean ...
    (microsoft.public.access.formscoding)
  • Re: Can I control which Tab is selected ... code to swap subform sourceObject
    ... The "command buttons" to switch subforms are colored so that you can see which one is active ... I define a calculated control on the subform and set it equal to the specified control on the main form for LinkMasterFields ... Dim mCurrentTab As Integer, i As Integer, mBoo As Boolean ...
    (microsoft.public.access.forms)
  • Re: Is this a Sound Database Design? -- code: SwitchTabs
    ... The "command buttons" (put in quotes because I actually used label controls) to switch subforms are colored so that you can see which one is active ... TabID is an unbound control -- it is set when the form loads ... Sometimes, the subforms do not have linking fields, like a lookup subform ... Dim mCurrentTab As Integer, i As Integer, mBoo As Boolean ...
    (microsoft.public.access.tablesdbdesign)