Open Args not filtering

  • Thread starter Ray Deron via AccessMonster.com
  • Start date
R

Ray Deron via AccessMonster.com

I'm on a form and trying to open another form based on the filenum. The
first form is the main from. Then I want to click on a button to log
activity on that record, but can get the 2nd form to filter. Please help!

Ray
ON CLICK OF THE ACTIVITY BUTTON I WANT TO OPEN THE CONTACTS FORM TO THE FILE
NUMBER THAT IS CURRENTLY OPEN…..

Private Sub LogActivity_Click()

Dim rs As Object

Set rs = Me.Recordset.Clone
DoCmd.OpenForm "contacts", , , , , , [FileNum]

End Sub


IN THE ON-OPEN OF THE CONTACT FORM I HAVE THE FOLLOWING:

Private Sub Form_Open(Cancel As Integer)
Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone

If Len(Me.OpenArgs) > 0 Then
rs.FindFirst "Filenum=" & Me.OpenArgs
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If

End Sub
 
R

Rob Oldfield

Putting it in square brackets doesn't say "This field belongs to the rs
recordset" Try rs!filenum instead

(..or add a filenum control to the calling form and use me.filenum)
 
M

Marshall Barton

Ray said:
I'm on a form and trying to open another form based on the filenum. The
first form is the main from. Then I want to click on a button to log
activity on that record, but can get the 2nd form to filter. Please help!

Ray
ON CLICK OF THE ACTIVITY BUTTON I WANT TO OPEN THE CONTACTS FORM TO THE FILE
NUMBER THAT IS CURRENTLY OPEN…..

Private Sub LogActivity_Click()

Dim rs As Object

Set rs = Me.Recordset.Clone
DoCmd.OpenForm "contacts", , , , , , [FileNum]

End Sub


IN THE ON-OPEN OF THE CONTACT FORM I HAVE THE FOLLOWING:

Private Sub Form_Open(Cancel As Integer)
Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone

If Len(Me.OpenArgs) > 0 Then
rs.FindFirst "Filenum=" & Me.OpenArgs
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
End If

End Sub


That code does not try to filter the contacts form, if it
worked, it would just position the current record to match
the OpenArgs number.

You never did say what it does do or if there are any error
messages, so I'm kind of shootin in the dark here.

I think you should use the WhereCondition argument instead
of OpenArgs. This has the added benefit of not needing any
code in the contacts form.

Private Sub LogActivity_Click()
DoCmd.OpenForm "contacts", _
WhereCondition:= "FileNum=" & Me.FileNum
End Sub

If the FileNum field in the tables is a Text field then use:

DoCmd.OpenForm "contacts", _
WhereCondition:= "FileNum=""" & Me.FileNum & """"
 

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