+ Reply to Thread
Results 1 to 4 of 4

Data type mismatch - excel userform to access table

  1. #1
    Registered User
    Join Date
    10-22-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    32

    Data type mismatch - excel userform to access table

    HI, I am using the code below to send data from a excel userform to an access table. I get a data mismatch at the line ".Fields("account_no").Value = textname2" In access this is a number field. If I the user fills in the account number in the user form, the data is submitted correctly. If they leave it blank then they get the data type mismatch. How can I avoid this error. I need the form to be submitted regardless or not if the field is blank.

    Thanks in advance.

    Please Login or Register  to view this content.
    .Update
    End With

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Data type mismatch - excel userform to access table

    Hi chinaboy,

    How about using a zero if the userform field is blank? Would Access like a zero better than a blank? Do you have validation turned on for that field in Access? Is it required and nulls allowed, in the Access table definition?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    10-22-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Data type mismatch - excel userform to access table

    Yes access will allow a zero, but I rather it not have a zero the field. I do not have validation turned on for that field in access. The field is not a required field and I am not sure how to check if nulls are allowed.

  4. #4
    Registered User
    Join Date
    10-22-2009
    Location
    Raleigh, NC
    MS-Off Ver
    Excel 2003
    Posts
    32

    Re: Data type mismatch - excel userform to access table

    I am still having trouble correcting this this error. It seems like the userform is submiting spaces and when I hover over the compile error . I tried the code below to try to get it to submit as empty, but that didn't work. What else can I do to make sure when the userform data is submitted to access the blank field is really empty? This field is a numeric field, not sure if this makes a different. But if I put a value in the field it works perfectly. But the field in not required and don't want to force the user to enter a value.

    Please Login or Register  to view this content.
    I found this solution in another post, but this seems like it goes to a spreadsheet first before going to Access. My user form should send the data directly to access.

    Please Login or Register  to view this content.
    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1