Solved

Using r.FindFirst and getting Data Type Mismatch

Posted on 2003-11-21
3
656 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
  • 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 …

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now