run-time error, "can't recognise ContactId" when using FindFirst

R

Rocky

I am curently wotking on a customer db.

I have two forms, on with summary information and one with customer
records.

Both are based on the same recordset.

I have written the code below, where I first doulble click on the
CustomerId ("ConId") - Long Integer". I then use the FindFirst below,
to search for the actual cusomer record.

I get a run-time error, "can't recognise ContactId"

When I debug, "ConId" shows the value of the CustomerID.

I have looked at similar posts, but they all seem to refer to text
finds.


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

If Not IsNull(Me.ConId) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Open Form where Customer Records are kept
DoCmd.OpenForm "CustCard", acNormal, "", "", , acNormal
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[ContactId] = " & Me.ConId
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If


End Sub
 
G

Guest

If you are trying to open a different form to display a specific record, why
not just use the WHERE arguments for the DoCmd.OpenForm method?

DoCmd.OpenForm "CustCard", acNormal, "", "[ContactId] = " & Me.ConId , ,
acNormal

HTH
 
R

Rocky

If you are trying to open a different form to display a specific record, why
not just use the WHERE arguments for the DoCmd.OpenForm method?

DoCmd.OpenForm "CustCard", acNormal, "", "[ContactId] = " & Me.ConId , ,
acNormal

HTH



Rocky said:
I am curently wotking on a customer db.
I have two forms, on with summary information and one with customer
records.
Both are based on the same recordset.
I have written the code below, where I first doulble click on the
CustomerId ("ConId") - Long Integer". I then use the FindFirst below,
to search for the actual cusomer record.
I get a run-time error, "can't recognise ContactId"
When I debug, "ConId" shows the value of the CustomerID.
I have looked at similar posts, but they all seem to refer to text
finds.
Private Sub ConId_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
If Not IsNull(Me.ConId) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Open Form where Customer Records are kept
DoCmd.OpenForm "CustCard", acNormal, "", "", , acNormal
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "[ContactId] = " & Me.ConId
If rs.NoMatch Then
MsgBox "Not found: filtered?"
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub- Hide quoted text -

- Show quoted text -

I have already tried your sugestion, and it works. The only problem is
that I have two filter (conbo boxes) on the form that is linked to the
underlying query, both using the "Like" command (Like [Forms]!
[CustCard]![MagFilter] and Like [Forms]![CustCard]![SearchCompany].

I thought the FindFirst would alleviate the problem. The sql for the
quey reads as follows:-

SELECT Contacts.ContactId, Magazine.Magazine, Contacts.Company,
Contacts.PO_Box, Contacts.PO_Box2, Contacts.PO_City, Contacts.PO_Code,
Contacts.Street, Contacts.Suburb, Contacts.City, Contacts.Code,
Contacts.Tel, Contacts.Status, Contacts.Attach, Contacts.[Sales
Person], Contacts.StatusRead
FROM Magazine INNER JOIN Contacts ON Magazine.MagId =
Contacts.Magazine
WHERE (((Magazine.Magazine) Like [Forms]![CustCard]![MagFilter]) AND
((Contacts.Company) Like [Forms]![CustCard]![SearchCompany]));

The whole idea about the filters is to choose a particular magazine
and then quick seaarch the clients on the Customer record form.

Is there a way to re-write the sql to say that when the form is opened
from the summary data form, then ignore the two filters.

Thanks

Rocky
 

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

Similar Threads

FindFirst 3
Issue with checking if number already exists using .FindFirst 2
Run-time error '424' 2
FindFirst Problem 2
Bookmark Issue 7
FindFirst quit working 1
Recordset FindFirst 4
FindFirst not working 2

Top