strSQL = "SELECT * FROM IIS_N WHERE (((IIS_N.TypeCode)=" & TypeCode & ") AND ((IIS_N.CityCode)=" & CityCode & ") AND ((IIS_N.LookThrough)=True) AND ((IIS_N.Current)=True));"
在本地窗口窗口中出来的是
"SELECT * FROM IIS_N WHERE (((IIS_N.TypeCode)=IISP) AND ((IIS_N.CityCode)=SH) AND ((IIS_N.LookThrough)=True) AND ((IIS_N.Current)=True));"
IISP和SH没有引号
怎么办呢
正确的应该是的到这一句:
SELECT * FROM IIS_N WHERE (((IIS_N.TypeCode)="IISP") AND ((IIS_N.CityCode)="SH") AND ((IIS_N.LookThrough)=True) AND ((IIS_N.Current)=True));
KindCode = Left(TypeCode, 3)
Set Conn = CurrentProject.Connection
Select Case KindCode
Case "IIS"
CityCode = DLookup("[IIS_CityCode]", "da_JBXX", "[EmployeeID]= " & EmployeeID & "")
strSQL = "SELECT * FROM IIS_N WHERE IIS_N.CityCode='" & CityCode & "' AND left(IIS_N.TypeCode,3)='" & TypeCode & "' and ((IIS_N.Offer)=True)"
Rec.Open strSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
Do While Not Rec.EOF
Offer = Rec.Fields("Offer")
If Offer = False Then
P = 0
C = O
Exit Sub
End If
If TypeCode = "IISZ" Then
P_value = Rec.Fields("Value_P")
C_value = Rec.Fields("Value_C")
P = P_value
C = C_value
Else
P_rate = Rec.Fields("Rate_P")
C_rate = Rec.Fields("Rate_C")
BS = BaseMoney(CityCode, KindCode, Base)
P = BS * P_rate
C = BS * C_rate
End If
Rec.MoveNext
Loop