Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data Type Mismatch (A2K / SQL Server 2K)

    I created a view in SQL Server (it's a ton faster then the query in Access!). I have a report that uses the view and I can get the correct data by putting in an "On Load" command for the report. What I want to do is set a variable using the "On Current" of a previous subform. From there I will select the criteria from the view.

    Now, my problem is that I am using the following code to try and get info from the view:

    1. me.recordsource = "Select * from dbo_qryincidentreport3 where [est_id] = '" & asEstimate1 & "';"

    It is returning a data type mismatch on this string. I have made sure that the variable asEstimate1 is set for "Long" and the Est_id is a number in the table. If I go like this:

    2. me.recordsource = "Select * from dbo_qryincidentreport3 where [est_id] = 20714;"

    it works and returns the correct record. Even though asEstimate1 is a number, is the ('" & asEstimate1 & "') in line 1 above turning it into a string instead? If so, what is the syntax on the first line above that will allow asEstimate1 to remain a number?

    Thanks,
    Mark Santos

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Data Type Mismatch (A2K / SQL Server 2K)

    I think the issue may be the order of the single quote and double quote items - at least I get tangled up with them every so often. In any event, the SQL statement has to be a string to start with so it can get process by Jet. If you really want to get creative, you can use a stored procedure with a parameter, and return only the records you are interested in directly, but that might well involve using a pass-through query. But first try tinkering with the order of (") and (').
    Wendell

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data Type Mismatch (A2K / SQL Server 2K)

    As a follow on to Wendell's reply, I would try deleting the single quote (') altogether. On line 2 (your example that works), I don't see a single quote at all. Of course, it may be my eyes!

    HTH.
    Carol W.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •