473,763 Members | 8,423 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type Mismatch Error

26 New Member
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 each SQL statement using a MsgBox and then input that exact code as a Query in access which works. I'm using Access 97 on Windows XP. My code is below:

Dim strKaizen As String
strKaizen = "UPDATE KaizenEvents SET(TeamLeader) = '" & [TeamLeader] & "' WHERE ProjectCode=" & [ProjectCode] & " "
DoCmd.RunSQL (strKaizen)

If Nz(Form.AI1) > 0 Then
Dim strActionItems1 As String
strActionItems1 = "INSERT INTO ActionItems (ProjectCode, ActionItem, POC, Status) " & _
"VALUES(" & [ProjectCode] & ",'" & [AI1] & "','" & [POC1] & "'," & [AIStatus1] & ")"
DoCmd.RunSQL (strActionItems 1)
End If

If Nz(Form.AI2) > 0 Then
Dim strActionItems2 As String
strActionItems2 = "INSERT INTO ActionItems (ProjectCode, ActionItem, POC, Status) " & _
"VALUES(" & [ProjectCode] & ",'" & [AI2] & "','" & [POC2] & "'," & [AIStatus2] & ")"
DoCmd.RunSQL (strActionItems 2)
End If

If Nz(Form.Goal1) > 0 Then
Dim strGoals1 As String
strGoals1 = "INSERT INTO Goals (ProjectCode, Goals, Status) " & _
"VALUES(" & [ProjectCode] & ",'" & [Goal1] & "'," & [GoalStatus1] & ")"
DoCmd.RunSQL (strGoals1)
End If

If Nz(Form.Goal2) > 0 Then
Dim strGoals2 As String
strGoals2 = "INSERT INTO Goals (ProjectCode, Goals, Status) " & _
"VALUES(" & [ProjectCode] & ",'" & [Goal2] & "'," & [GoalStatus2] & ")"
DoCmd.RunSQL (strGoals2)
End If

Dim strTeam As String
strTeam = "INSERT INTO TeamMembers (ProjectCode,Te amMember1,TeamM ember2,TeamMemb er3,TeamMember4 ,TeamMember5,Te amMember6,TeamM ember7,TeamMemb er8,TeamMember9 ,TeamMember10,T eamMember11,Tea mMember12,TeamM ember13,TeamMem ber14) " & _
"VALUES(" & [ProjectCode] & ",'" & [TmMbr1] & "','" & [TmMbr2] & "','" & [TmMbr3] & "','" & [TmMbr4] & "','" & [TmMbr5] & "','" & [TmMbr6] & "','" & [TmMbr7] & "','" & [TmMbr8] & "','" & [TmMbr9] & "','" & [TmMbr10] & "','" & [TmMbr11] & "','" & [TmMbr12] & "','" & [TmMbr13] & "','" & [TmMbr14] & "')"
DoCmd.RunSQL (strTeam)

I know that a mismatch occurs when one is trying to insert the wrong data type into a field. I have checked and rechecked my fields.
Status field = number
ProjectCode = number
Everything else = text

I have three tables that are related by the ProjectCode field. The Kaizen field has an autonumber primary key and the other ProjectCodes are just number fields with duplicates OK. I have this code on a form that will allow a user to input data that will then be sent to the appropriate table. There is a goals table, an action items table, and a team members table as there can be multiple occurrences of these items per unique kaizen event in the main table.

Can anyone spot why I may have a data mismatch error?

Additionally, if you have a suggestion for a better way to write the "Nz(....) >0 piece, that would be good too. I'm basically trying to avoid null and empty cells in the DB.

Thanks in advance
Dec 6 '06 #1
5 2848
nico5038
3,080 Recognized Expert Specialist
Is hard to do without the actual code.
In this case I normally place a Break in the code (click in the left rules to get a brown dot) and execute the sub.
When the code halts I use the F8 to step one line after the assign statement of the SQL string.
Then type in the immediate window:
?strSQL
and press [Enter] to get the build SQL.
This I copy/paste in the SQL mode of the query editor and Access will give the error and place the cursor at the erroneous field.
There I correct the statement till it works and then amend the original string.

Nic;o)
Dec 6 '06 #2
kjworm
26 New Member
Well, as soon as I posted, I figured out that the "If Nz(Form.AI1) > 0 Then" piece of the code is causing my problems. This requires the "AI1" field to be numeric. If I enter text I get the Type Mismatch Error, but if I enter numbers, everything works fine.

What I am trying to do is create an entry into the DB only if a user populates the form. If the entry field is blank, then nothing will be inserted into the DB. What would be the best way to do this?
Dec 6 '06 #3
nico5038
3,080 Recognized Expert Specialist
That's the reason I use for the "empty" check:

IF Len(NZ(field))> 0 then ....

This works for both text and numbers being Null or empty.

Nic;o)
Dec 6 '06 #4
kjworm
26 New Member
I just replaced the Nz with Len and it works fine. I'll add in what you suggest and take it from there.

Thanks! This answers my question!
Dec 6 '06 #5
nico5038
3,080 Recognized Expert Specialist
Glad I could help, success with your application !

Nic;o)
Dec 6 '06 #6

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

Similar topics

5
4438
by: Arun Wadhawan | last post by:
Hello MY SQL Server is causing me this problem : Microsoft VBScript runtime error '800a000d' Type mismatch: 'ident' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I am getting from the table datingnew the value of the ident field.
1
2492
by: LJgrnl | last post by:
I've got a type mismatch error that's driving me nutty. Variable blnNoData has the initial value False. If a recordset comes back empty (both .EOF and ..BOF are true) then blnNoData is set to True. I then have an if statement to determine what to write to the screen depending on blnNoData. As long as the if statement is true (doesn't have to go to the else clause), the code runs fine. Otherwise, a type mismatch error is returned. In...
4
11967
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 14 (STDCOST). ---End Error Msg--- The STDCOST is set to decimal (28,14) and is a formatted in Access as a number, single with 14 decimal. I don't know why I would be getting a Type
0
2254
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 that will run fine without any criteria but as soon as I add any criteria it gives a "Data type mismatch" error. As soon as I remove any criteria it runs perfectly. I know this query is based on another query but I have other processes based on...
3
2916
by: amitbadgi | last post by:
I am getting teh following error while converting an asp application to asp.net, Exception Details: System.Runtime.InteropServices.COMException: Type mismatch. Source Error: Line 347: 'response.Write(sql2)
1
2817
by: Brett | last post by:
I have a form that calls a method within a DLL. By clicking a button on the form, the DLL is instantiated and the SaveOutlookMessage() method invoked. The DLL code copies messages from Outlook to an HTML file. When I execute the EXE, which is only the form, and click the button, I get a "Type Mismatch" error on this line in the form: mailobj.SaveOutlookMessage() Any suggestions on why I'm getting the type mismatch error? --Form code
6
5998
by: Howard Kaikow | last post by:
I'm doing a VB 6 project in which I am trying to protect against type mismatch errors. Is the process any different in VB .NET? Here's what I'm doing in VB 6. I have an ActiveX DLL. The class has stuff initialized by calling a sub SetClass that wants some Word specific objects passed-in. If the user mistakingly uses the wrong object, say, uses an Excel object
1
1671
by: jodyblau | last post by:
I have a database which works fine until I create and MDE file. Once I create the MDE, when I open a particular form I get a "Type Mismatch" error. Because its an MDE file, I can't step through the code to find out where the error is occuring; and (as I mentioned earlier) when I go back to the oriignal database the problem doesn't exist. Any ideas of what is going on here and how to fix it? Thanks,
19
5545
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were working fine for the past years but recently our website was updated in that old folders were renamed and the new ones took on the existing name and was wondering why some our ..asp pages are now returning this error? I would think that since the code
1
2838
by: nckinfutz | last post by:
hello, I am having a problem with an access database. this is not my database and I did not create it, nor am I very good at access. however, I am a network engineer and that is why this problem has ended up in my lap i guess. This is the issue: There is an access database that pulls data from a list of excel spread sheets. This access database and excel files are stored on a server. When the database requests info from the excel file...
0
9387
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.