Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Access Query has a datatype mismatch

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
Wedmore
Asked:
Wedmore
1 Solution
 
peter57rCommented:
True should work.   (as should False)

Can you post the full sql of the problem query.
0
 
als315Commented:
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
 
Don ThomsonCommented:
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
 
WedmoreAuthor Commented:
Sorry the coder says that its working now.  He said he set the properties of the column, in design mode, to True/False.
0
 
WedmoreAuthor Commented:
Sorry - problem was solved on their own.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now