Run time error 13 - Type Mismatch (1 Viewer)

tech69

Registered User.
Local time
Today, 15:12
Joined
Jul 31, 2008
Messages
14
Hello All

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

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

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

Thanks for any and all assistance :eek:
 

DCrake

Remembered
Local time
Today, 15:12
Joined
Jun 8, 2005
Messages
8,632
You may need to disambiguate between ADO and DAO

Dim Rst As DAO.Recordset
Dim MyDb As DAO.Database
 

tech69

Registered User.
Local time
Today, 15:12
Joined
Jul 31, 2008
Messages
14
Your a star

thank you
 

tpickrel

Registered User.
Local time
Today, 10:12
Joined
Mar 12, 2010
Messages
17
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
 

MarkK

bit cruncher
Local time
Today, 07:12
Joined
Mar 17, 2004
Messages
8,181
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.
 

Users who are viewing this thread

Top Bottom