HalloweenWeed
Member
- Local time
- Today, 03:10
- Joined
- Apr 8, 2020
- Messages
- 220
Hello,
I am trying to manipulate data from an Access table linked to Sharepoint, in a new database in Access 2016 or Office 365 Access. I have the link working successfully. In particular, one field that I have to do some conversion on to convert it to a numeric value. Unfortunately, it is a text format field, when it should be a numeric (I have no control over it). Since the data entry person sometimes puts a "MR" prefixing the number, I have to to some checking of that, remove it, and convert to a number (integer, no decimals). That works fine. FYI Sharepoint often transfers a field of type "calculated value," but this is not the case here, as I have done checking with "VarType" (within the Query), and they come in as type 1 and 8 only. So I do subqueries to work only with type 3 (Long Int). Full disclosure, here is the Field Query algorithm:
It works fine. It also filters out the Nulls and zeros. I then created a subquery to make certain that the data is converted to Long Int:
SQL:
And I checked the vartype with another field in the query:
It reports nothing but 3's (Long Int, no Nulls). But the problem I get, is when I set any sort on the "MR" field, I get "Type Mismatch" error when I try to run it. I even tried in desperation making a sub-subquery, to make certain that it was only looking at Long Int values, but still I get the same error trying to sort the "MR" field.
I also get the same "Type mismatch" error when I try to sort from the dates (within the query), and they all show as type 7: Date value. This one is crucial to my end goal.
Any ideas? I can sort all the other fields (one text, one text numbers with a hyphen, one autonumbered by Sharepoint). I have searched the internet for this problem, but I can find no applicable answers, and none at all involving Sharepoint data (could it be a Sharepoint-related problem?).
I am trying to manipulate data from an Access table linked to Sharepoint, in a new database in Access 2016 or Office 365 Access. I have the link working successfully. In particular, one field that I have to do some conversion on to convert it to a numeric value. Unfortunately, it is a text format field, when it should be a numeric (I have no control over it). Since the data entry person sometimes puts a "MR" prefixing the number, I have to to some checking of that, remove it, and convert to a number (integer, no decimals). That works fine. FYI Sharepoint often transfers a field of type "calculated value," but this is not the case here, as I have done checking with "VarType" (within the Query), and they come in as type 1 and 8 only. So I do subqueries to work only with type 3 (Long Int). Full disclosure, here is the Field Query algorithm:
Code:
MR: IIf(IsNull([MR #]),CLng(0),IIf(Len([MR #])>2,IIf(Left([MR #],2) Like "MR",CLng(Val(Right([MR #],Len([MR #])-2))),CLng(Val([MR #]))),IIf(Val([MR #])>0,CLng(Val([MR #])),CLng(0))))
It works fine. It also filters out the Nulls and zeros. I then created a subquery to make certain that the data is converted to Long Int:
Code:
MR: CLng([RawData]![MR])
SQL:
Code:
SELECT RawData.ID, RawData.[Incident #: ID], RawData.[Unit:], CLng([RawData]![MR]) AS MR, VarType([MR]) AS MR_VarTyp, RawData.[Last Name, First Name], RawData.[Date of Incident:], VarType([Date of Incident:]) AS Date_VarTyp, RawData.Seclusion, RawData.[Total Seclusion Time], VarType([Total Seclusion Time]) AS Time_VarTyp
FROM RawData
WHERE (((CLng([RawData]![MR]))<>0) AND ((RawData.Seclusion)=True) AND ((RawData.[Total Seclusion Time])>"0") AND (([RawData]![MR]) Is Not Null));
Code:
MR_VarTyp: VarType([MR])
It reports nothing but 3's (Long Int, no Nulls). But the problem I get, is when I set any sort on the "MR" field, I get "Type Mismatch" error when I try to run it. I even tried in desperation making a sub-subquery, to make certain that it was only looking at Long Int values, but still I get the same error trying to sort the "MR" field.
I also get the same "Type mismatch" error when I try to sort from the dates (within the query), and they all show as type 7: Date value. This one is crucial to my end goal.
Any ideas? I can sort all the other fields (one text, one text numbers with a hyphen, one autonumbered by Sharepoint). I have searched the internet for this problem, but I can find no applicable answers, and none at all involving Sharepoint data (could it be a Sharepoint-related problem?).
Last edited: