Bilbo_Baggins_Esq
Registered User.
- Local time
- Today, 16:13
- Joined
- Jul 5, 2007
- Messages
- 586
Ok, I’m stumped.
Connecting Access FE to SQL SERVER BE
Connection is fine.
I can open and close it and other queries work fine.
I have only one problem with the SQL in one query
So, the first time I run through this, there is no problem (if FirstRecord = True).
It runs fine and vbMinOf3OrderID receives the value of “WS10001894”.
The problem comes on the NEXT run, (if FirstRecord = False)
It throws an error:
I have already tried several obvious modifications and none seems to work.
Connecting Access FE to SQL SERVER BE
Connection is fine.
I can open and close it and other queries work fine.
I have only one problem with the SQL in one query
Code:
With rstRPT
If FirstRecord = True Then
.Open "SELECT Min([" & SourceTbl & "].[3Order ID]) AS MinOf3OrderID " & _
"FROM [" & SourceTbl & "];" _
, cnn1, adOpenUnspecified, adLockUnspecified
Else
.Open "SELECT Min([" & SourceTbl & "].[3Order ID]) AS MinOf3OrderID " & _
"FROM [" & SourceTbl & "] " & _
"WHERE ((([" & SourceTbl & "].[3Order ID]) > " & Chr(34) & vbMinOf3OrderID & Chr(34) & "));" _
, cnn1, adOpenUnspecified, adLockUnspecified
End If
End With
vbMinOf3OrderID = rstRPT!MinOf3OrderID
It runs fine and vbMinOf3OrderID receives the value of “WS10001894”.
The problem comes on the NEXT run, (if FirstRecord = False)
It throws an error:
Any ideas why it wants to see the variable as a column name?Run-time error ‘-2147217900 (80040e14)’:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column-name ’WS10001894’.
I have already tried several obvious modifications and none seems to work.