Can someone help me?.How to alert data in Form automatically without clicking into the datagrid.I need to pop up the message box when the medicines expired without clicking in the datagrid. I have a table name inventory field names MedicineName, genericname, StockQuantity,"Expmonth", "Expday", "Expyear".

here is my code

Private Sub DataGrid1_Click()
On Error Resume Next
With frm_ScrollUP

    .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 "OK!", vbInformation, "Working"
    MsgBox "Medicine Expired!.", vbExclamation, "   Warning!"

    If MsgBox("Do you want to delete " & Text4 & "?", vbQuestion + vbYesNo, "Message") = vbYes Then
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"

End sub

The answer is already on your code (line 12 - 25), just place it on the correct event.

You can try the form's load or activate event. You'll figure it out eventually.

Good luck.

Maybe use a timer event to fire the alert.

@abelingaw It works Sir for only one medicine but how about If I have two or more expired medicines?. How can I alert them all?
Please help me thank you

Ok. To alert the user using a pop up is kinda annoying if there are more than 1 item nearly expired. You don't want 10 + msgbox popping up upon form load.

I guess it would be better if you could just use another control, say label to notify the user if a specific item (Selected) is nearly expired.

Anyway, base on your code, it seems you let user to select an item one by one. Try using a listview instead?

Just a suggestion though, up to you.

you can even count the no. of items expiring and display them in the alert box at one go......