Access 2007 Clicking In Record on Form To Same Record Different Fo

M

Mag14

Help!!
E.G. form 1 with a sub form attached.
Form 2 basic details of main form 1.

I want to beable to click in Form 2 record/Command button and find
same record in Form 1. (These details I want to find are in the main form not
the sub form).
I have tried wizard on command button but this will only link to Form 1 not
record. This was after selecting record section of wizard. This is in Access
2007
 
J

June7 via AccessMonster.com

I have used DAO recordset clone, FindFirst method, Bookmark property to move
to record of form’s recordset. Ex:
Public Sub ViewData(strDirection)

Dim cn As ADODB.Connection
Dim rs As DAO.Recordset

Set cn = CurrentProject.Connection
Set rs = Form_SampleInfo.RecordsetClone

If Not IsNull(Form_SampleInfo.tbxViewDataFormNAME) Then
DoCmd.Close acForm, Form_SampleInfo.tbxViewDataFormNAME, acSaveNo
End If

rs.Bookmark = Form_SampleInfo.Bookmark
If strDirection = "Quit" Then
DoCmd.Close acForm, "SampleInfo", acSaveNo
' Form_SampleManagement.tbxLabNum.SetFocus
ElseIf strDirection = "Next" Then
rs.MoveNext
If Not rs.EOF Then
DoCmd.GoToRecord acForm, "SampleInfo", acNext
Form_SampleInfo.btnPrevious.Enabled = True
Else
rs.MoveLast
MsgBox "Last record."
Form_SampleInfo.btnNext.Enabled = False
Form_SampleInfo.btnPrevious.Enabled = True
End If
ElseIf strDirection = "Previous" Then
rs.MovePrevious
If Not rs.BOF Then
DoCmd.GoToRecord acForm, "SampleInfo", acPrevious
Form_SampleInfo.btnNext.Enabled = True
Else
rs.MoveFirst
MsgBox "First record."
Form_SampleInfo.btnPrevious.Enabled = False
Form_SampleInfo.btnNext.Enabled = True
End If
End If

End Sub
 
J

June7 via AccessMonster.com

Edit: Here's is the example using FindFirst method:

Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone

rs.FindFirst "StateNum='" & Me.lbxStateProjItemPre.Column(0) & "'" & _
" AND ItemNo='" & Nz(Me.lbxStateProjItemPre.Column(2), "") & _
"' AND PREFIX='" & Me.lbxStateProjItemPre.Column(3) & "'"
Me.Bookmark = rs.Bookmark
I have used DAO recordset clone, FindFirst method, Bookmark property to move
to record of form’s recordset. Ex:
Public Sub ViewData(strDirection)

Dim cn As ADODB.Connection
Dim rs As DAO.Recordset

Set cn = CurrentProject.Connection
Set rs = Form_SampleInfo.RecordsetClone

If Not IsNull(Form_SampleInfo.tbxViewDataFormNAME) Then
DoCmd.Close acForm, Form_SampleInfo.tbxViewDataFormNAME, acSaveNo
End If

rs.Bookmark = Form_SampleInfo.Bookmark
If strDirection = "Quit" Then
DoCmd.Close acForm, "SampleInfo", acSaveNo
' Form_SampleManagement.tbxLabNum.SetFocus
ElseIf strDirection = "Next" Then
rs.MoveNext
If Not rs.EOF Then
DoCmd.GoToRecord acForm, "SampleInfo", acNext
Form_SampleInfo.btnPrevious.Enabled = True
Else
rs.MoveLast
MsgBox "Last record."
Form_SampleInfo.btnNext.Enabled = False
Form_SampleInfo.btnPrevious.Enabled = True
End If
ElseIf strDirection = "Previous" Then
rs.MovePrevious
If Not rs.BOF Then
DoCmd.GoToRecord acForm, "SampleInfo", acPrevious
Form_SampleInfo.btnNext.Enabled = True
Else
rs.MoveFirst
MsgBox "First record."
Form_SampleInfo.btnPrevious.Enabled = False
Form_SampleInfo.btnNext.Enabled = True
End If
End If

End Sub
Help!!
E.G. form 1 with a sub form attached.
[quoted text clipped - 6 lines]
record. This was after selecting record section of wizard. This is in Access
2007
 

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