标题: 我下面的語句不知怎麽不管用呀??? [打印本页] 作者: sunguochang 时间: 2002-10-22 16:40 标题: 我下面的語句不知怎麽不管用呀??? 這個語句我是想,當我輸入一個日期時,讓它與LD_COLOUR_HISTROY表中的EVENT(事件)的APPROVED的日期相比較。
Private Sub txti_Change()
strSQL = "select * from [LD_COLOUR_HISTORY] where ([hld]='" & HLD_no.Value & "') and ([colour]='" & Colour.Value & "') and ([event]='approved')"and (colour='" & Colour.Value & "')"
rst.Open strSQL, CurrentProject.Connection, adOpenStatic, adLockReadOnly
Dim txti As Date, dt1 As Date
If rst("event") = "approved" Then dt1 = rst("date")
If (txti - dt1) > 0 Then
MsgBox "沒有超期,在客戶規定的期限內將樣品交出了!" & "txti-dt1"
ElseIf (txti - dt1) = 0 Then
MsgBox "剛好,在客戶規定的期限內將樣品交出了!" & "txti-dt1"
Else
MsgBox "超期警告!!!" & "txti-dt1"
End If
End Sub
作者: WTM1 时间: 2002-10-22 18:00
strSQL = "select * from [LD_COLOUR_HISTORY] where ([hld]='" & HLD_no.Value & "') and ([colour]='" & Colour.Value & "') and ([event]='azS作者: shweiw 时间: 2002-10-25 18:28
这很明显是语句错了,多了个"在([event]='approved')"后面的"是多余的作者: kexiaoke 时间: 2002-11-19 19:09
shweiw 说的对作者: sunguochang 时间: 2002-11-19 21:43 标题: 谢谢我已经解决了 语句如下:
Dim strsql As String
Dim j As Integer
Dim rst As New ADODB.Recordset
strsql = "select top 1 edate from ld_colour_history where (hld='" & HLD.Value & "') and (colour='" & Colour & "') and (event ='" & approved & "') order by edate desc"
rst.Open strsql, CurrentProject.Connection, adOpenStatic
rst.MoveLast
j = DateDiff("d", Text11.Value, rst("edate"))
If j > 0 Then
MsgBox "请注意,这个已经超期了'" & j & "'天"
ElseIf j < 0 Then
MsgBox "在客户规定的期限内完成,并少用了'" & j & "'天"
Else
MsgBox "与客户所需的日期相同"
End If
End Sub
[em26]