7,762
社区成员
发帖
与我相关
我的任务
分享
Private Function GetFTNNo(ByVal sFTNNo As String, ByVal sPart As String) As Boolean
Dim strSQL As String
Dim rdors As RDO.rdoResultset
Dim bFirst As Boolean
Dim strLotNo As String
On Error GoTo Handle_Err
If cnQIMS.State = adStateClosed Then
cnQIMS.Open
End If
strLotNo = sFTNNo
If InStr(1, strLotNo, "R") > 0 Then
strLotNo = Left(strLotNo, Len(strLotNo) - 2)
End If
strSQL = "select ftnlot_nbr, ftnlot_remarks_2 from ftnlot_mstr where ftnlot_nbr like '" & strLotNo & "%'"
Debug.Print strSQL '输出拿到数据库运行
With cmdGetCompany
.Parameters("@part").Value = sPart
.Execute
If Trim(.Parameters("@company").Value) = "" Then
GetFTNNo = False
Remark = "Can not get company code"
Exit Function
End If
'-----------这两个没有什么差别,执行一样的语句
If Trim(.Parameters("@company").Value) = "welco" Then
Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
End If
If Trim(.Parameters("@company").Value) = "wellop" Then
Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
End If
'------------
End With
If Not rdors.EOF Then
GetFTNNo = False
Remark = Trim(rdors("ftnlot_remarks_2"))
Else
GetFTNNo = True
End If
Set rdors = Nothing
Exit Function
Handle_Err:
blOpenL1000DB = False
Set rdors = Nothing
GetFTNNo = False
Remark = ""
Err.Clear
End Function
' If Trim(.Parameters("@company").Value) = "welco" Then
' Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
' End If
'
' If Trim(.Parameters("@company").Value) = "wellop" Then
' Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
' End If
'问题描述:
'此函数用来查询仓单在MFG/PRO中的状态,若存在则不上传该FTN No资料,读取其备注信息
'(ftnlot_remarks_2),函数置假;否则则上传其资料,函数置真。
'问题在于现在我在MFG/PRO中可查询到某仓单的信息,但rdors.EOF却为真,即无该仓单资料。
'请各位达人帮忙看看,该函数的问题所在,多谢!
'-----------Function: Get FTN No exists status
'---------Parameters: sFTNNo : FTN No
'-------------------- sPart : Part No
'--------Create Date: 06/15/2010
Private Function GetFTNNo(ByVal sFTNNo As String, ByVal sPart As String) As Boolean
Dim strSQL As String
Dim rdors As RDO.rdoResultset
Dim bFirst As Boolean
Dim strLotNo As String
On Error GoTo Handle_Err
If cnQIMS.State = adStateClosed Then
cnQIMS.Open
End If
strLotNo = sFTNNo
If InStr(1, strLotNo, "R") > 0 Then
strLotNo = Left(strLotNo, Len(strLotNo) - 2)
End If
strSQL = "select ftnlot_nbr, ftnlot_remarks_2 from ftnlot_mstr where ftnlot_nbr like '" & strLotNo & "%'"
With cmdGetCompany
.Parameters("@part").Value = sPart
.Execute
If Trim(.Parameters("@company").Value) = "" Then
GetFTNNo = False
Remark = "Can not get company code"
Exit Function
End If
'-----------这两个记录不是并存吧?
' If Trim(.Parameters("@company").Value) = "welco" Then
' Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
' End If
'
' If Trim(.Parameters("@company").Value) = "wellop" Then
' Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
' End If
'是要这个?
If Trim(.Parameters("@company").Value) = "welco" Then
Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
ElseIf Trim(.Parameters("@company").Value) = "wellop" Then
Set rdors = cnWongDB.OpenResultset(strSQL, rdOpenForwardOnly, rdConcurReadOnly)
End If
'------------
End With
Debug.Print rdors.recordcount '加这个看输出,是否有记录?
If Not rdors.EOF Then
GetFTNNo = False
Remark = Trim(rdors("ftnlot_remarks_2"))
Else
GetFTNNo = True
End If
Set rdors = Nothing
Exit Function
Handle_Err:
blOpenL1000DB = False
Set rdors = Nothing
GetFTNNo = False
Remark = ""
Err.Clear
End Function