I'm having a problem with a button in MS Access querying a SQL View that doesn't have a foreign key.
My question is VERY similar to the question found here: MS Access error "ODBC--call failed. Invalid character value for cast specification (#0)" -- That seems to be my exact problem, but I'm not sure how to resolve it. Here are some more details. First, the exact error message:
ODBC--call failed.
[Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification (#0)
Here's where I differ. I have a button in MS Access that does the following:
Private Sub btnMachineCutSheet_Click()
Dim stDocName As String
stDocName = "qryCutSheetByMachines"
DoCmd.OpenQuery stDocName, acNormal, acEdit
End Sub
The query you see listed there (qryCutSheetByMachines) is a pretty long query, but I've narrowed the problem down to one line. Here's the query:
SELECT
vwCutSheet.Network,
vwCutSheet.NetworkSpeed,
vwCutSheet.Duplex
FROM vwCutSheet
INNER JOIN local_tblCreateCutSheet
ON vwCutSheet.EquipmentID = local_tblCreateCutSheet.EquipmentID;
Keep in mind that all the tables/views are linked tables from a MS SQL 2008 database
The first bit of oddness is that everything works just fine if I remove the vwCutSheet.NetworkSpeed, line. Unfortunately, I need that data.
Now, if I take out the JOIN statement the query works fine. Obviously I need the join or I wouldn't have it there. Now, the problem (I assume) is that the view (vwCutSheet) does not have a PK (should views have primary keys?). vwCutSheet.EquipmentID cannot be a PK though because there will usually always be a case of multiple EquipmentID's with the same value in this view.
And the last bit of information that might be messing things up is this. If I open up the view in Design view (in MS Access) I can see that Access is expecting a data type of "Number" - but if I look at the table that the view queries from originally, the data type is a varchar(5). I expect that Access is looking at the contents of the data and seeing nothing but numbers (values are 10,100,1000, and 10000).
I'm happy to say I didn't design this, so it's not my fault! Hah... but, I do have to support it, so it's up to me to make it work.
So... I think that's all the pertinent info. Let me know if you require more info and I'll edit my question as we go along.
Thanks in advance for any help!
EDIT: More info found:
The table that the view pulls from uses a column with a varchar(5) data type. The reason that field is a varchar(5) is because it's possible to specify a 'speed' of 10, 100, 1000, 10000, or Auto.
Additionaly, it is possible for the populated field in the view to be null.