Solved

Using r.FindFirst and getting Data Type Mismatch

Posted on 2003-11-21
3
663 Views
Last Modified: 2008-03-10
I have a form with two search combo boxs from it I have a list of Envelope numbers in one box and a list of Names in another box.  My first Combo box is labeled SearchEnvNo
and my second box is labeled
SearchLastNameFirst

After the update of information in the box my underlying form is suppose to display the appropriate record based on the search criteria.  My 2nd box which is searching for a string (LastnameFirst) works.  But I can't figure out how to enter the R.FindFirst for an Integer which is what EnvNo is.    My code stops at the     R.FindFirst ("[EnvNo] = " & Chr(34) & Me![SearchEnvNo] & Chr(34))

with the error Data Type Mismatch in Criteria Expression.
*********************************
my code so far looks like this:
************************************
(This one does not work- Data type mismatch)

Private Sub SearchEnvNo_AfterUpdate()
    Dim R As Recordset
    Set R = Me.RecordsetClone
    R.FindFirst ("[EnvNo] = " & Chr(34) & Me![SearchEnvNo] & Chr(34))
    Me.Bookmark = R.Bookmark
    Me![SearchEnvNo] = Null
End Sub
**********************************
(This one Works)
Private Sub SearchLastNameFirst_AfterUpdate()
    Dim R As Recordset
    Set R = Me.RecordsetClone
    R.FindFirst ("[LastnameFirst] = " & Chr(34) & Me![SearchLastnameFirst] & Chr(34))
    Me.Bookmark = R.Bookmark
    Me![SearchLastnameFirst].Value = ""
End Sub

***********************************
Can someone help me with the code I need to be able to search for an integer from my Field EnvNo  my combo box is unbound but I don't have anything set for Format

Randy
0
Comment
Question by:rronne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
jobrienct earned 125 total points
ID: 9801789
try changing

R.FindFirst ("[EnvNo] = " & Chr(34) & Me![SearchEnvNo] & Chr(34))

to

R.FindFirst ("[EnvNo] = "  & Me![SearchEnvNo] )

regards,

John
0
 

Author Comment

by:rronne
ID: 9801867
Thanks John,  that is just what it took.  I knew I was getting close but I just could not seem to figure it out.

Randy
0
 
LVL 10

Expert Comment

by:jobrienct
ID: 9801898
Glad to help

John
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question