Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 04-17-2018, 06:57 AM   #1
jeran042
Newly Registered User
 
Join Date: Jun 2017
Posts: 61
Thanks: 17
Thanked 0 Times in 0 Posts
jeran042 is on a distinguished road
Runtime Error 13 - Type Mismatch

Im sure Im missing something so obvious, but cant seem to troubleshoot it. I am getting a type mismatch on the following code:

Code:
Private Sub Text2_Click()

Dim iCost_Center As Integer
Dim sCategory As String
Dim sWhere As String
Dim sFormName As String


iCost_Center = Me.txtCOST_CENTER
sCategory = Me.txtTemp_Month_Temp_Per
sWhere = "[COST_CENTER] = " & iCost_Center And "[CATEGORY] = " & "'" & sCategory & "'"   'This is the line throwing up the error
sFormName = "frm: Ledger Detail"


DoCmd.OpenForm sFormName, acViewNormal, , sWhere, , acDialog


End Sub
Can someone point out what I'm doing wrong?
Very much appreciated!!

jeran042 is offline   Reply With Quote
Old 04-17-2018, 10:08 AM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 31,679
Thanks: 9
Thanked 3,796 Times in 3,739 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Runtime Error 13 - Type Mismatch

I moved your post out of the moderated code repository forum.

For starters, the "And" needs to be inside the quotes; you have it outside.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is offline   Reply With Quote
Old 04-17-2018, 10:52 AM   #3
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 11,989
Thanks: 56
Thanked 1,093 Times in 999 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Runtime Error 13 - Type Mismatch

Paul is right.

That is also the cause of your type mismatch. Since the "AND" is not quoted, what you are doing is the expression

Code:
iCost_Center And "[CATEGORY] = "
where you are doing the AND of an integer and a string constant. That is your mismatch.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Type mismatch (runtime error 13) pgilling Modules & VBA 3 04-22-2013 12:14 AM
Runtime Error 13 Type Mismatch berg Modules & VBA 3 11-23-2012 10:44 AM
Runtime error 13: Type mismatch aman Modules & VBA 3 03-07-2012 03:54 PM
Runtime Error 13 Type mismatch CharlesWhiteman Modules & VBA 2 09-19-2010 09:07 AM
Runtime Error 13 Type Mismatch coolcatkelso General 2 01-24-2009 03:42 PM




All times are GMT -8. The time now is 04:56 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World