473,385 Members | 1,693 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,385 software developers and data experts.

I keep getting a Type Mismatch error when i run this recordset

Dim m_MeetingName, m_City, m_title As String
Dim m_sql As Long
Dim dbs As Database, rst, rst2 As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Related Conference Categories", dbOpenTable)

rst.MoveFirst
Do Until rst.EOF
m_City = "*"
m_title = "*"
m_MeetingName = rst("RelatedConference")
MsgBox rst("RelatedConference")



m_sql = "SELECT Count([Sourcecodes Test].ClientID) AS CountOfClientID FROM ([Related Conference Categories] INNER JOIN [Sources Test] ON [Related Conference Categories].RelatedConference = [Sources Test].[Related Conferences]) INNER JOIN [Sourcecodes Test] ON [Sources Test].[Source Code] = [Sourcecodes Test].SourceCode WHERE ((([Sources Test].[Related Conferences]) '" & m_City & "' & '" & m_MeetingName & "' & '" & m_title & "' ));"
Sep 23 '10 #1
2 1355
colintis
255 100+
Check the data type of your table if they are matching your vba codes or not, mostly this is cause by the variables compare to the table data types are not the same.

Also, please use CODE TAGS ([CODE ] & [/ CODE]) when you are posting codes.

Welcome to Bytes!
Sep 23 '10 #2
OldBirdman
675 512MB
I have NOT attempted to duplicate this situation or run the code. I have not tested my code. Without knowing where it fails, I do note the following:
1) DIM Statements may not be correct. The statement
Expand|Select|Wrap|Line Numbers
  1. Dim m_MeetingName, m_City, m_title As String
only declares m_title as String. The other two variables are Variant. This also occurs in another DIM Statement.

2)
Expand|Select|Wrap|Line Numbers
  1. m_City = "*"
  2. m_title = "*"
never change, and should be moved out of the Do Until ... loop

3) The WHERE clause of the SQL assigned into m_sql seems to be wrong. If I assume [Related Conferences] has the value 'ABCDEFXYZ' and m_MeetingName the value 'CDE' then the WHERE clause is
Expand|Select|Wrap|Line Numbers
  1. ... WHERE (((ABCDEFXYZ) '* ' & ' CDE ' & '*' ))
I think it should be more like
Expand|Select|Wrap|Line Numbers
  1. ... WHERE (('ABCDEFXYZ') LIKE '*CDE*'))
which would be
Expand|Select|Wrap|Line Numbers
  1. m_sql = "... WHERE ((([Sources Test].[Related Conferences]) LIKE '*" & m_MeetingName & "*'));"
in the m_sql = ... statement.

Could you do a Debug.Print of m_sql or a MsgBox m_sql after the m_sql = "SELECT ...;" statement and post the result?
Sep 24 '10 #3

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

Similar topics

4
by: leslie_tighe | last post by:
Hello, I have a method on a com+ object that is returning an array of objects. I know the array is popluated as calls to check the ubound and lbound show valid values. However, any calls to...
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...
19
by: sara | last post by:
I am getting "Type Mismatch Error" when the following code executes. I am trying to notify the user if she attempts to add a customer with the same FirstName, LastName, Address(line1) and City as...
4
by: tomlebold | last post by:
Why do I receive a Type mismatch error when running the following code, which has a SQL Server 2000 back end database? The error occurs on the following line: Set rs = db.OpenRecordset(SQL,...
3
by: zarar | last post by:
Hi to everyon i have a problem plz help me when i filter a recordset by date in vb and ms access and enter the any date of month 04/2007 i get the error msg as type mismatch but i works for...
1
by: mstrjohn | last post by:
I am using access as the front end to a mysql database using linked tables. I have a table called dailytrx that has all the transactions, there are 2 fields that I am concerned with, a date and a...
6
by: sara | last post by:
Hi - I have the code below and it errors with "Type Mismatch" on the last line. I have no idea why. The query is based on one table. Table has 2 fields: Key (autonum) and PONumber (Long) ...
2
by: dstorms | last post by:
Hi, I am trying to write code that opens a form using data highlighted from a listbox, but I keep getting Type Mismatch errors. I finally ran a test code and still got the error message. Dim...
7
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am...
3
by: James Watson | last post by:
'Microsoft VB 6.3, Access 2002 'Syntax error in the INSERT INTO Statement when the query runs 'How can I make this work? Private Sub Command52_Click() On Error GoTo Err_Command52_Click ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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,...
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...

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.