4 Replies - 406 Views - Last Post: 10 July 2017 - 02:13 PM Rate Topic: -----

#1 Levin_G  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 10-July 17

Data Type Mismatch for filtering a Data Type Number

Posted 10 July 2017 - 01:31 PM

I have field name in the Database Item_No and I made the Data Type Number so that I can sort the number 1 to 10 in proper order, but when I'm trying to filter a certain Estimation_No and Item_No I am getting an ERROR of Data Type Mismatch. This only works if I change the Data Type of the Item_No to Long Text.

How can I filter a certain Estimation_No and Item_No without changing the Data Type of Item_No?

my codes are as follow:



Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
                
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.MDB;Persist Security Info=False"
rs.Open "select * from Table1 where Estimation_No='" & txtEstNo.Text & "' and Item_No ='" & txtID.Text & "'", conn, 3, 3

:code:



Thanks...

This post has been edited by modi123_1: 10 July 2017 - 01:32 PM
Reason for edit:: In the future please use the [code] button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: Data Type Mismatch for filtering a Data Type Number

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13492
  • View blog
  • Posts: 53,895
  • Joined: 12-June 08

Re: Data Type Mismatch for filtering a Data Type Number

Posted 10 July 2017 - 01:34 PM

Please remember to use the '[code ]' button in the editor.

I would suggest using parameters and not just trying to append it in some dynamic string.

I would also suggest looking up what happens when something is surrounded by tick marks. Hint - make the term a varchar string.
Was This Post Helpful? 1
  • +
  • -

#3 Levin_G  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 10-July 17

Re: Data Type Mismatch for filtering a Data Type Number

Posted 10 July 2017 - 01:46 PM

View Postmodi123_1, on 10 July 2017 - 01:34 PM, said:

Please remember to use the '[code ]' button in the editor.

I would suggest using parameters and not just trying to append it in some dynamic string.

I would also suggest looking up what happens when something is surrounded by tick marks. Hint - make the term a varchar string.



sorry about the code thing sir. I'm kinda new so I'm still getting use to posting. Anyway, can you please give me a sample codes for using parameters or varchar something because I really don't have any idea about it. I will really appreciate your help sir.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13492
  • View blog
  • Posts: 53,895
  • Joined: 12-June 08

Re: Data Type Mismatch for filtering a Data Type Number

Posted 10 July 2017 - 01:59 PM

Is this really VB6 or VB.NET?
Was This Post Helpful? 0
  • +
  • -

#5 Levin_G  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 10-July 17

Re: Data Type Mismatch for filtering a Data Type Number

Posted 10 July 2017 - 02:13 PM

View Postmodi123_1, on 10 July 2017 - 01:59 PM, said:

Is this really VB6 or VB.NET?



its VB6 sir.. I got it now sir. I removed the ' in the sql statement for the Item_No. Now it's working.

rs.Open "select * from Table1 where Estimation_No='" & txtEstNo.Text & "' and Item_No = " & txtID & "", conn, 3, 3





Thanks :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1