Error: Type Mismatch - access + vb 6.0

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Error: Type Mismatch - access + vb 6.0

 
0
  #1
Aug 17th, 2009
I'm having this error: type mismatch.. i dont actually get/understand the error.. i think the error is in the WHERE clause [tblUserAccount].[UserID].. the field [UserID] is set to a data type Autonumber, and the roleUserID is set as integer..

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Global rolesDbs as new adodb.connection
  3. Global rolesRs as new adodb.recordset
  4.  
  5. rolesDbs.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\library.mdb;MODE=ReadWrite"
  6. rolesDbs.CursorLocation = adUseClient
  7. Set rolesRs.ActiveConnection = rolesDbs
  8. rolesRs.LockType = adLockOptimistic
  9. rolesRs.CursorType = adOpenDynamic
  10. rolesRs.Source = "SELECT [tblRoles].[UserID], [tblRoles].[Role] " & _
  11. "FROM [tblUserAccount] INNER JOIN [tblRoles] ON ([tblUserAccount].[UserID] = [tblRoles].[UserID]) " & _
  12. "WHERE [tblUserAccount].[UserID] = " + roleUserID + ""
  13. rolesRs.Open , rolesDbs, , , adCmdText

help me out here please.. thanks
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 828
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 150
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #2
Aug 17th, 2009
You cannot "add" strings together (+), you can however concatinate strings together (&). As for everything else, it looks fine at first glance.


Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #3
Aug 17th, 2009
well if i tried changing the (+) sign using the (&) sign the error now changes to: Data type mismatch in criteria expression. So how's that? I'm not actually concatinating it, im comparing it using the WHERE clause.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #4
Aug 17th, 2009
try this
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "WHERE [tblUserAccount].[UserID] = '" & roleUserID & "'"
single quotes around roleuserid
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #5
Aug 17th, 2009
Originally Posted by ProfessorPC View Post
try this
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "WHERE [tblUserAccount].[UserID] = '" & roleUserID & "'"
single quotes around roleuserid
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "WHERE [tblMembership].[UserID] ='" & Trim(roleUserID) & "'"
in this code if i place a single quotes the error is "Data type mismatch in criteria expression." but if i remove the single quotes, what will happen is that i am already concatinating the string together, which causes an error..
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #6
Aug 17th, 2009
if you are pulling data from one table only why use the join?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "SELECT UserID, Role FROM tblRoles where UserID = '" & roleUserID & "'"
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #7
Aug 18th, 2009
I ain't actually getting data from only one table, i need some datas also from the other table that's why i applied the INNER JOIN, i just don't know why it shows an error with the WHERE clause.. please, need back up ..
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #8
Aug 18th, 2009
in your query you are only pulling from one table. i guess its throwing me off. what are the fields from the other table you are using? can you test your query in your db's query analyser?
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 41
Reputation: JerieLsky is an unknown quantity at this point 
Solved Threads: 0
JerieLsky JerieLsky is offline Offline
Light Poster

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #9
Aug 19th, 2009
Originally Posted by ProfessorPC View Post
in your query you are only pulling from one table. i guess its throwing me off. what are the fields from the other table you are using? can you test your query in your db's query analyser?
Ok, i tried this Query from only one table which is Table Membership:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. "SELECT * FROM [tblMembership] WHERE [tblMembership].[UserID] = '"+ rolesUserID + "'"

if i remove the WHERE clause, i get no errors, but if place that WHERE clause in the Query it pops up the error: Type Mismatch. In the table Membership, i set the data type of UserID to Number, and the variable rolesUserID to Integer.
The rolesUserID is actually a variable that i have set to make a comparison to [tblMembership].[UserID].

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. rolesUserID = usersRs.Fields("UserID").Value

i dont know what's causing the problem.
Last edited by JerieLsky; Aug 19th, 2009 at 1:57 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 828
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 150
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: Error: Type Mismatch - access + vb 6.0

 
0
  #10
Aug 19th, 2009
Seems like user id is a numeric field. Remove the single ticks (') from around your variable.



Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC