Solved

Access Query has a datatype mismatch

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

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

856 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