Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    9

    Exclamation Unanswered: Database Problem?

    hi all...im using a n access db and vb6...
    i have a program that i select a table, that is stored in a db, and do some adding to it...i keep getting a "Type Mismatch" error...

    does anyone know where my problem is???
    here is my code...

    Set db = OpenDatabase("C:\test\orders.mdb")
    Set rs2 = db.OpenRecordset(cmbTables.Text, dbOpenDynaset)
    TempName = txtName.Text
    TempDate = txtDate.Text
    TempNumber = txtNumber.Text
    TempOrder = txtOrder.Text

    rs2.AddNew
    rs2!Name= TempName
    rs2!Date = TempDate
    rs2!Number = TempNumber
    rs2!Order = TempOrder

    rs2.Update
    MsgBox "Item Added Successfully!!" _
    , vbInformation, "Added"
    rs2.Close
    Set rs2 = Nothing
    db.Close
    Set db = Nothing
    Unload Form4
    Load Form4
    Form4.Show
    End Sub

    real simple code...thanks for your time....

  2. #2
    Join Date
    Aug 2004
    Posts
    82
    Was the database created in MS access 2000 or higher

  3. #3
    Join Date
    Jul 2004
    Posts
    69
    hi there! I supposed that the data type designated in your table for the value of txtNumber (TempNumber) is a "Number" data type...if so, you can have this code

    instead of: TempNumber = txtNumber.Text

    change to: TempNumber = Val(txtNumber.Text)

    and check all possible "mismatch" data types...

  4. #4
    Join Date
    Nov 2003
    Location
    Sussex, England
    Posts
    404

    Casting

    It might be worthwile to cast all your variables into the correct type, e.g.

    TempDate = CDATE(txtDate.Text)

    It might be useful to find line is chucking up the error.


Posting Permissions

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