473,408 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Type mismatch:Runtime error 13

Expand|Select|Wrap|Line Numbers
  1. For r = 2 To 28
  2.  
  3.  
  4. Do While Len(Range("A" & r).Formula) > 0
  5. rs.AddNew
  6. rs.Fields(0) = Range("A" & r).Value
  7. rs.Fields(1) = Range("C" & r).Value
  8. 'Debug.Print r & ":(" & Range("D" & r).Value & ")"
  9. rs.Fields(2) = CLng(Range("D" & r).Value)
  10. rs.Fields(3) = Range("G" & r).Value
  11. rs.Fields(4) = Range("J" & r).Value
  12. 'rs.Fields(5) = CLng(Range("L" & r).Value)
  13. 'Debug.Print CLng(Range("L" & r).Value)
  14. rs.Fields(6) = CLng(Range("O" & r).Value)rs.Update
  15. r = r + 1
  16. Loop
  17. Next r
As seen in the attached file the first 2 record are inserted in the table.But Im getting Type mismatch error for the highlighted statements.

Can anyone Plz help me to rectify this..
Attached Files
File Type: txt outer3.txt (606 Bytes, 447 views)
Feb 12 '10 #1
8 5061
NeoPa
32,556 Expert Mod 16PB
Please ask a clear question without requiring us to go round the houses just to work out what you want.

A good start in an Access / VBA forum is to make it clear you are working in Excel.
Feb 12 '10 #2
ADezii
8,834 Expert 8TB
There are more than likely 2 possible explanations:
  1. The Values in the specific Column(s) where the Error(s) occur cannot be coerced to a LONG Data Type.
  2. The underlying Field in the Table representing the Recordset is not a comparable Data Type to LONG.
  3. If neither of these solve the problem, Attach the Spreadsheet if possible, and we'll have a look at it.
Feb 12 '10 #3
Can u just go thru the attached file...

In this file the first 2 records are getting inserted but it gives me error for the columns "Gsteel" & last column "Qty"..

The datatype for both this columns is Long..So how do i rectify these code becoz i m getting error for these lines of code.
rs.Fields(5) = CLng(Range("L" & r).Value)
Debug.Print CLng(Range("L" & r).Value)
rs.Fields(6) = CLng(Range("O" & r).Value)
.
Feb 22 '10 #4
ADezii
8,834 Expert 8TB
It may be getting hung up because of NULLS in the 2 Fields mentioned, try:
Expand|Select|Wrap|Line Numbers
  1. rs.Fields(5) = Nz(Range("L" & r).Value)
  2. rs.Fields(6) = Nz(Range("O" & r).Value)
Feb 22 '10 #5
Thanks alot ADezii...but can u Plz tell me how to use Nz function in vba code as Excel does not support Nz fuction..

Can u Plz let me know...
Feb 22 '10 #6
ADezii
8,834 Expert 8TB
At this point, I'm simply guessing. How about Uploading the Spreadsheet with the accompanying code, and I'll be glad to look at it.
Feb 22 '10 #7
NeoPa
32,556 Expert Mod 16PB
Nz() is an Access function.

If you add the Microsoft Access library reference to your Excel project you will be able to use Nz().
Feb 22 '10 #8
Add References some is missing..
Feb 22 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mike | last post by:
I am getting a type mismatch error when I do a bulk insert. ---Begin Error Msg--- Server: Msg 4864, Level 16, State 1, Line 1 Bulk insert data conversion error (type mismatch) for row 1, column...
3
by: Martin Lacoste | last post by:
Is there some issue with using too many left/right/mid/len functions in queries? Depending on the usage, they work fine, but... then there's here: SELECT Master_CAO.Incipit,...
0
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
6
by: shan | last post by:
What is the meaning for the error expression syntax and type mismatch error.I am using turbo c++.can anybody correct the errors in the folowing program. Following program is to find matrix...
1
by: jodyblau | last post by:
I am getting a type mismatch message under strange circumstances. Here's whats going on: 1. I have split the database into a front end and a back end. 2. I have compiled the project. 3. ...
2
by: Rehan | last post by:
Hi there! Please help me out here. I am an inch away from completing my assignment. I am very new to VBA but i have very less time to be efficient at it. I am getting a type mismatch error...
5
by: kjworm | last post by:
Hello Everyone, I have been fighting with a type mismatch error for many hours today and I can't seem to find what the problem is. Hopefully it is more than a missing apostrophe! I have isolated...
7
by: Mike | last post by:
Type Mismatch error I recieve a type mismatch error on the following line of code which is based on a specific date. It does NOT break on all records only "some". The dates for the records...
5
by: Lara1 | last post by:
Hi, I'm a total beginner to VBA, so please bear with me if I seem a bit dense. What I'm Trying to Achieve I'm trying to write a procedure in Excel, which is supposed to - look at the pH...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.