Solved

Access Query has a datatype mismatch

Posted on 2011-02-28
5
255 Views
Last Modified: 2012-05-11
The below coding returns a true or false for based on the Lan ID and the Province.  Using this in a query we would have

SELECT LanID, Prov(LanID, Forms1!txtProvince) AS Permissions
    FROM StaffTable

The column "Permissions" will return true or false if the staff member has the permissions for that province.  However, when we try to add a filter on the Permissions column, it returns a data type mismatch error.  In the Design mode I put either 1 or True or T and nothing works.  Any ideas why?






Public Function Prov(LANID As String, Province As String) As Boolean

Dim TempValue As Boolean
    
TempValue = False

Select Case Province
    Case "NS"
        Select Case LANID
            Case "E1857", "E807138"
                TempValue = True
            Case Else
                TempValue = False
        End Select
        
    Case "NB"
        Select Case LANID
            Case "X157", "X382"
                TempValue = True
            Case Else
                TempValue = False
        End Select
End Select

Prov = TempValue

End Function

Open in new window

0
Comment
Question by:Wedmore
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 34999584
True should work.   (as should False)

Can you post the full sql of the problem query.
0
 
LVL 39

Expert Comment

by:als315
ID: 34999763
Are you sure, StaffTable not have null values in LanID field?
Try also:
SELECT LanID, Prov(StaffTable.LanID, Forms1!txtProvince) AS Permissions
    FROM StaffTable

0
 
LVL 14

Expert Comment

by:Don Thomson
ID: 35001294
Check the tables and see if there are any records that are Null  - Neither true or false - That would cause a data mismatch error

If the number of records are large then just do a quick query that says update all records that are not TRUE to false
0
 

Accepted Solution

by:
Wedmore earned 0 total points
ID: 35001405
Sorry the coder says that its working now.  He said he set the properties of the column, in design mode, to True/False.
0
 

Author Closing Comment

by:Wedmore
ID: 35042728
Sorry - problem was solved on their own.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now