Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Data Type Mismatch Error

Discussion in 'Information Technology' started by j, Jul 28, 2006.

  1. j

    j
    Expand Collapse
    Guest

    I am working on a project and am getting a simple error that has me stumped.
    printout and 'may 2008$' are two recordsets/tables in this database. Each has
    matching information that I want to compare.The matching information is
    ExportID and Export. Both fields are strings (though they are all numeric
    characters). ID is a unique identifier beggining with 1 that is in the
    printout database but not 'may $2008'. However, I get a "data type mismatch
    in criteria expression" referring to the final line in the pasted text. Does
    anyone know how to fix this problem, thank you!!

    Dim dbMyDB As Database
    Set dbMyDB = OpenDatabase("myproject.mdb")

    Dim first As Recordset
    Set first = dbMyDB.OpenRecordset("printout", dbOpenDynaset)

    Dim second As Recordset
    Set second = dbMyDB.OpenRecordset("'May 2008'$", dbOpenDynaset)

    Dim custID As String
    Dim p As Double

    p = 1
    'later I will loop p to do this for many IDs

    first.FindFirst "ID = " & CStr(p)
    custID = first!ExportID
    second.FindFirst "[Export] = " & custID
     
  2. Loading...


  3. OP
    Ofer Cohen

    Ofer Cohen
    Expand Collapse
    Guest

    When you search on a string field, you need to add a single quote before and
    after the value, either wise it will treat it as a number, and this is why
    you are propmpt with type mismatch

    try
    first.FindFirst "ID = '" & CStr(p) & "'"


    --
    Good Luck
    BS"D


    "j" wrote:

    > I am working on a project and am getting a simple error that has me stumped.
    > printout and 'may 2008$' are two recordsets/tables in this database. Each has
    > matching information that I want to compare.The matching information is
    > ExportID and Export. Both fields are strings (though they are all numeric
    > characters). ID is a unique identifier beggining with 1 that is in the
    > printout database but not 'may $2008'. However, I get a "data type mismatch
    > in criteria expression" referring to the final line in the pasted text. Does
    > anyone know how to fix this problem, thank you!!
    >
    > Dim dbMyDB As Database
    > Set dbMyDB = OpenDatabase("myproject.mdb")
    >
    > Dim first As Recordset
    > Set first = dbMyDB.OpenRecordset("printout", dbOpenDynaset)
    >
    > Dim second As Recordset
    > Set second = dbMyDB.OpenRecordset("'May 2008'$", dbOpenDynaset)
    >
    > Dim custID As String
    > Dim p As Double
    >
    > p = 1
    > 'later I will loop p to do this for many IDs
    >
    > first.FindFirst "ID = " & CStr(p)
    > custID = first!ExportID
    > second.FindFirst "[Export] = " & custID
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page