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

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 03-23-2010, 04:32 AM   #1
tech69
Registered User
 
Join Date: Jul 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
tech69 is on a distinguished road
Run time error 13 - Type Mismatch

Hello All

Having some trouble with this bit of code, the error reports "Run time error 13 - Type Mismatch"

I've highlighted the line it seems to fail on...

Code:
  Dim mydb As Database, rst As Recordset
        Set mydb = CurrentDb()
        Const cQuote = """"  
        Set rst = mydb.OpenRecordset("TABLENAME")
Using Access 2003.

Thanks for any and all assistance

tech69 is offline   Reply With Quote
Old 03-23-2010, 04:36 AM   #2
DCrake
Administrator
 
DCrake's Avatar
 
Join Date: Jun 2005
Location: Burnley, Lancashire
Posts: 8,634
Thanks: 8
Thanked 313 Times in 208 Posts
DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light DCrake is a glorious beacon of light
Send a message via Skype™ to DCrake
Re: Run time error 13 - Type Mismatch

You may need to disambiguate between ADO and DAO

Dim Rst As DAO.Recordset
Dim MyDb As DAO.Database
__________________
David Crake


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
The Home of Simple Software Solutions.

O/S Windows XP (SP3) & Windows 7 64bit
Access 2003 (version 11.0)
Access 2007 (version 12.0)

Remember when posting sample databases you will get a better response if it is pre Access 2007 - not all people have it installed.
DCrake is offline   Reply With Quote
Old 03-23-2010, 04:50 AM   #3
tech69
Registered User
 
Join Date: Jul 2008
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
tech69 is on a distinguished road
Re: Run time error 13 - Type Mismatch

Your a star

thank you

tech69 is offline   Reply With Quote
Old 03-23-2010, 06:23 PM   #4
tpickrel
Registered User
 
Join Date: Mar 2010
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
tpickrel is on a distinguished road
Re: Run time error 13 - Type Mismatch

Got the same problem here is the code it fails on Access 2007, trying to make command buttons visible when a form opens for certian employees and not others.
Get a type 13 mismatch error.

If Me.LogInFrmUserIdTxt.Text = "Drb00" Or "tep09" Then
Forms!TimeEntryFrm.TimeEntryFrmOpenAddNewMemberFrm .Visible = True
Forms!TimeEntryFrm.TimeEntryFrmOpenDeleteMemberFrm .Visible = True
End If
tpickrel is offline   Reply With Quote
Old 03-23-2010, 11:12 PM   #5
MarkK
Super Moderator
 
MarkK's Avatar
 
Join Date: Mar 2004
Location: Vancouver BC
Posts: 7,761
Thanks: 10
Thanked 1,285 Times in 1,224 Posts
MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all
You can't do ...
Code:
"Drb00" Or "tep09"
... which is a boolean operation on strings. You need explicitly check the equality for each item and OR those results together, like ...
Code:
If Me.UserID = "Drb00" Or Me.UserID = "tep09" Then
Other observations:
Possibly 'LogInFrmUserIdTxt' is overkill, particularly if the item is a textbox on the Login form. Certainly there's no confusion about what the thing is, but it can make your code appear unnecessarily complicated. There's a balance somewhere.
You also might not need to explicitly use the .Text property. With textboxes you more commonly use the .Value property, which is the default and therefore not required in your code.

__________________
formerly known as lagbolt | Windows 10 | Access 2010 | Visual Studio 2013 | "Institutions have a vested interest in perpetuating the problems to which they are the solution." - Clay Shirky
MarkK 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 - 13 cpremo Modules & VBA 10 05-06-2011 04:29 AM
update table properties automatically lala Forms 8 12-11-2008 08:38 AM
type mismatch error beanbeanbean Forms 2 11-11-2008 07:40 AM
run time app mikeder General 0 02-18-2003 05:30 PM
Append Query Fails When 2 Users Run At Same Time sambo Modules & VBA 10 02-03-2003 02:14 PM




All times are GMT -8. The time now is 06:50 AM.


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