Hi, I'm hoping someone can help me with this code. I'm getting a 'Type
mismatch' error, and I'm not sure why. The SQL works fine in SQL view,
so I'm not sure if that's the problem or not.
This is a dumbed down version of what I'm trying to do so it looks like
more like an academic problem.
All I want at this stage is to get the highest value of table.id into a
variable.
Dim strSQL As String
Dim RS As Recordset
Dim strFileNum As String
strSQL = "SELECT table.id FROM [table] WHERE (((table.id) Like
""9001*""));"
Set RS = CurrentDb().OpenRecordset(strSQL)
With RS
.MoveFirst
strFileNum = !id
End With
lblFilenum.Caption = strFileNum
'Close the recordset
RS.Close
The full SQL statement looks like
"
SELECT table.id, table.a, Format(S([id]),""000"") AS Sort
FROM [table]
WHERE (((table.id) Like [Forms]![frm]![txtFileNum]+""*""))
ORDER BY Format(S([id]),""000"");
"
But I've left it out because it's long and confusing (and dosn't seem
to affect the problem at this stage.
TIA