Results 1 to 3 of 3

Thread: DataCombo - a bit long winded

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    I been getting type mismatch messages when users are addin a nw row to my database. I couldnt figure out what was causing them, as i couldnt recreate them on my pc no matter how hard I tried, so I decided to do a bit of investigating.

    I was using this type of structure to add a record
    Code:
    With Recordset
        .Addnew
        !Field1 = "Something"    
        !Field2 = "Something Else"
        .Update
    End With
    I set a variable to the name of each field before saving it, and displauyed it in the error handler, eg
    Code:
    On Error Goto ErrHandler
    Dim Fieldname as String
    
    With Recordset
        .Addnew
        Fieldname  = "Field1"
        !Field1 = "Something" 
        Fieldname  = "Field2"   
        !Field2 = "Something Else"
        .Update
    End With
    
    ErrHandler:
        Msgbox "Error saving " & Fieldname
    The errors all seemed to come from a field that used a DataCombo control. I had used the .MatchedWithList property to make sure that each item was in the list before it was saved. The contents of thelist were 2 letter airline codes, eg BA

    Increasing the field length for these fields solved the problem, but I would like to know why this error happened in the first place. The LEN() function tells me that an item selected from this list is only 2 characters in length.

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Len() tells you the length of the data, not of the structure.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    sureley if I'm selecting an Item from a list whose source is a 2 character long Char field in a db table, I should get a string with a lenth of 2 characters

Posting Permissions

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



Click Here to Expand Forum to Full Width