Solved

Access Query has a datatype mismatch

Posted on 2011-02-28
5
253 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

9 Experts available now in Live!

Get 1:1 Help Now