弹出警报VB6

弹出警报VB6,vb6,Vb6,有人能帮我吗。这件事让我很难受。我只需要在药物过期时显示一条警告消息。我的问题是,当我得到两种或更多过期药物时,它不会提醒所有药物。相反,它会提醒一种药物。请帮助 这是我的密码 Private Sub Form_Activate() On Error Resume Next With Main .Text4 = Adodc1.Recordset.Fields("MedicineName") .Text1.Text = Adodc1.Records

有人能帮我吗。这件事让我很难受。我只需要在药物过期时显示一条警告消息。我的问题是,当我得到两种或更多过期药物时,它不会提醒所有药物。相反,它会提醒一种药物。请帮助

这是我的密码

Private Sub Form_Activate()
    On Error Resume Next

    With Main
        .Text4 = Adodc1.Recordset.Fields("MedicineName")
        .Text1.Text = Adodc1.Recordset.Fields("genericname")
        .Text3.Text = Adodc1.Recordset.Fields("StockQuantity")
        .Combo3 = Adodc1.Recordset.Fields("Expmonth")
        .Combo4 = Adodc1.Recordset.Fields("Expday")
        .Combo5 = Adodc1.Recordset.Fields("Expyear")
    End With

    Dim expirationdate As Date
    expirationdate = CDate(Combo3 & "/" & Combo4 & "/" & Combo5)
    datepicker.Value = Format(Now, "MMM-DD-yyyy")
    If datepicker > expirationdate Then
        MsgBox Text4.Text & " is expired ", vbExclamation, "Warning!"
        If MsgBox("Do you want to dispose " & Text4 & "?", vbQuestion + vbYesNo, "Message") = vbYes Then
            Adodc1.Recordset.Delete
        ElseIf vbNo Then
            Exit Sub
        End If
    End If

End Sub

Private Sub Form_Load()
    Adodc1.CommandType = adCmdUnknown
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\clinic.mdb" & ";Persist Security Info=False"
    Adodc1.RecordSource = "select * from inventory order by Expyear asc"
    Adodc1.Refresh
    Adodc1.Refresh
End sub

您需要遍历记录集中的所有记录。目前,您仅对第一条记录进行操作

Do Until Adodc1.Recordset.EOF

    ' Assign values to textboxes, test date, etc.

    ' Fetch the next record...    
    Adodc1.Recordset.MoveNext

Loop

Bond是正确的,您需要迭代记录集以显示每个过期记录的消息

Private Sub Form_Activate()
    Dim expirationdate As Date

    On Error Resume Next    '<-- this is going to cause a problem if you never check for errors

    Adodc1.Recordset.MoveFirst    'make sure the control is positioned on the first record
    Do While Adodc1.Recordset.EOF = False    'loop over all of the records
        With Main
            .Text4.Text = Adodc1.Recordset.Fields("MedicineName")
            .Text1.Text = Adodc1.Recordset.Fields("genericname")
            .Text3.Text = Adodc1.Recordset.Fields("StockQuantity")
            .Combo3 = Adodc1.Recordset.Fields("Expmonth")
            .Combo4 = Adodc1.Recordset.Fields("Expday")
            .Combo5 = Adodc1.Recordset.Fields("Expyear")
        End With

        expirationdate = CDate(Combo3 & "/" & Combo4 & "/" & Combo5)
        datepicker.Value = Format(Now, "MMM-DD-yyyy")
        If datepicker > expirationdate Then
            MsgBox Text4.Text & " is expired ", vbExclamation, "Warning!"
            If MsgBox("Do you want to dispose " & Text4 & "?", vbQuestion + vbYesNo, "Message") = vbYes Then
                Adodc1.Recordset.Delete
            End If
        End If
        Adodc1.Recordset.MoveNext
    Loop

End Sub
Private子表单_Activate()
Dim到期日期为日期
出现错误时,恢复下一个“到期日期”
MsgBox Text4.Text&“已过期”,vb感叹号,“警告!”
如果MsgBox(“是否要处置”&Text4&“?”,vbQuestion+vbYesNo,“Message”)=vbYes,则
Adodc1.Recordset.Delete
如果结束
如果结束
Adodc1.Recordset.MoveNext
环
端接头

先生,这是我所做的。我还有同样的问题。看来我的代码错了。我不知道如何循环。我的vb不是很好直到Adodc1.Recordset.EOF Adodc1.Recordset.Fields(“MedicineName”)=Text4.Text Adodc1.Recordset.Fields(“genericname”)=Text1.Text Adodc1.Recordset.Fields(“StockQuantity”)=Text3.Text Adodc1.Recordset.Fields(“Expmonth”)=Combo3.Text Adodc1.Recordset.Fields(“Expday”)=Text Adodc1.Recordset.Fields(“Expyear”)=Combo5.Text Adodc1.Recordset.MoveNext循环“看起来您是在为记录集赋值,而不是像在原始帖子中那样从记录集赋值。您不想改为
Text4.Text=Adodc1.Recordset(“MedicineName”)
?这将把值从记录集复制到文本框中。然后,在这个循环中添加你的日期检查代码,你就可以开始了。先生,我对text4有个问题,它只分配了一个值。我所需要的只是同时显示所有过期药品,而不必获取text4中记录集的值。怎么做,先生?也许你应该在你的表格中添加一个列表框,并将过期药品添加到列表框中?你需要一些方法来展示多种药物。列表框比消息框更有效。先生,你能给我举个例子吗?我不知道怎么做。谢谢,先生,但是怎么能同时显示两种或更多过期药品呢?我对Text4有一个问题,它只指定一个值。请查看我对代码所做的更改。它将继续循环,直到所有记录都被处理。它现在可以工作了,先生谢谢:)但是当我试图显示不同表中过期药品的价值时,我仍然有问题。这给了我一个错误。先生,你能看一下我的第二封信吗。非常感谢。