How to link 2 forms??

  • Thread starter Thread starter paulgaurav
  • Start date Start date
P

paulgaurav

Guest
i am trying to make a database in MS Access'97.i want to link 2 forms with one another.for this purpose i am using a command button in form 1 to go to form 2.the link is working fine..as expected...but the problem is: everytime i click on the command button to go to form 2, form 2 shows the details starting from record no. 1......whereas i want to see the details of that record on form 2, which is shown on form 1.say for eg. ...i am looking at the details of record 5 on form 1, then i want that when i click command button to go to form 2, then form 2 should allso show the other details of record 5 and not start from record 1(as is happening now).please guide me how to do it.
 
if both of your forms have an id field you could do it like this

in the form_current of the first assign a global variable(declare in module) with the current ID like this

If Not IsNull(Me.Form!ApplicantID) Then
globalApplicantID = Me.Form!ApplicantID

End If

then in the activate event of the the second form this:

Dim rs As DAO.Recordset, nRecords As Long

Set rs = Me.RecordsetClone
nRecords = rs.RecordCount

If nRecords <> 0 Then
Me.RecordsetClone.FindFirst "ApplicantID = " & globalApplicantID
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
rs.Close

you could also put this in the on open event but putting it in the on activate event means that once you have opened the second form, changed record on the first form and click back on the second form it should also display the same record as the first one.

cheers,
Ewen.
 

Users who are viewing this thread

Back
Top Bottom