Solved

Using r.FindFirst and getting Data Type Mismatch

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

831 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