Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Finding a record


Message #1 by "wambui njoroge" <kagdw189@b...> on Tue, 31 Dec 2002 00:30:36
Hi all,

I have two forms that open simultenously. When I open form1, form2 opens 
in invisible mode. I then clik on a button to view form2 and viceversa. 
When I view form2, I would like to go to the record that I was editing on 
form1. Both forms are continous forms.

Thanks.
Wambui.
Message #2 by "Bob Bedell" <bobbedell15@m...> on Tue, 31 Dec 2002 04:33:42 +0000
Hi Wambui,

I have Form1 and Form2 both based on a simple Employee's table. You can
clone Form2's recordset, search the cloned recordset by a criteria
passed from Form1's current record (EmployeeID), then bookmark Form2 at
the matching record. A reference to DAO isn't required. The Clone
method is a DAO method and returns a DAO recordset. You could set a
reference to DAO and use Dim rst As DAO.Recordset if you want. The Sub
that follows goes behind your command button on Form1.

Private Sub cmdViewForm2_Click()

    Dim strFormName As String
    Dim strCriteria As String
    Dim frm As Form
    Dim rst As Object

    If IsNull(Me.txtEmployeeID) Then
        Exit Sub
    End If

    strFormName = "Form2"

    'Check to see if Form2 is open. If not, open it. Hide Form1.
    If Not SysCmd(acSysCmdGetObjectState, acForm, strFormName) Then
        DoCmd.OpenForm strFormName
        Me.Visible = False
    End If

    Set frm = Forms(strFormName)
    Set rst = frm.Recordset.Clone

    strCriteria = "[EmployeeID] =" & Me!txtEmployeeID

    'Synch Form2 with Form1's current record.
    rst.FindFirst strCriteria
    If rst.EOF Then
        MsgBox "No match", 64, strFormName
    Else
        frm.Bookmark = rst.Bookmark
    End If

End Sub

Form2 just needs a command button with something like the following:

Private Sub cmdViewForm1_Click()
    Me.Visible = False
    Forms!Form1.Visible = True
End Sub

When you click the command button on Form2, you will return to the
record on Form1 that was passed to Form2, even if you've navigated off
the corresponding record in Form2.

Give it a whirl...

Bob



>From: "wambui njoroge" <kagdw189@b...>
>Reply-To: "Access" <access@p...>
>To: "Access" <access@p...>
>Subject: [access] Finding a record
>Date: Tue, 31 Dec 2002 00:30:36
>
>Hi all,
>
>I have two forms that open simultenously. When I open form1, form2 opens
>in invisible mode. I then clik on a button to view form2 and viceversa.
>When I view form2, I would like to go to the record that I was editing on
>form1. Both forms are continous forms.
>
>Thanks.
>Wambui.


_________________________________________________________________
MSN 8 with e-mail virus protection service: 3 months FREE*. 
http://join.msn.com/?page=features/virus&xAPID=42&PS=47575&PI=7324&DI=7474&SU= 
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_eliminateviruses_3mf


  Return to Index