Solved

Access Query has a datatype mismatch

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

831 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