I am trying to create an alert in Vb.6 code that tells the user to make purchase since he has riched limit of the product

Dani AI

Generated

raised a common need: notify when stock reaches a reorder threshold. Building on 's database approach (and answering 's request for clarity), the reliable pattern is: store a reorder threshold per product, detect products at-or-below that threshold, then present or record an alert. For single-user apps you can check in the VB6 client; for multi-site or unattended monitoring prefer a DB job or stored procedure that runs on the server.

A compact VB6 workflow:

  • Add fields like ProductID, ProductName, CurrentQty, ReorderLevel, ReorderQty, SupplierID, LastAlertDate.
  • Run a query that returns rows where CurrentQty <= ReorderLevel.
  • Aggregate the results and show one alert (do not pop a MsgBox per product).
  • Optionally update LastAlertDate to avoid duplicate alerts until stock changes.

Example VB6 snippet (requires a reference to Microsoft ActiveX Data Objects):

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql As String
Dim msg As String

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=SQLOLEDB;Data Source=YOURSERVER;Initial Catalog=YourDB;Integrated Security=SSPI;"
cn.Open

sql = "SELECT ProductName, CurrentQty, ReorderLevel FROM Products WHERE CurrentQty <= ReorderLevel"
Set rs = cn.Execute(sql)

If Not rs.EOF Then
  msg = "Reorder required:" & vbCrLf
  Do While Not rs.EOF
    msg = msg & rs!ProductName & " - " & rs!CurrentQty & " (reorder @ " & rs!ReorderLevel & ")" & vbCrLf
    rs.MoveNext
  Loop
  MsgBox msg, vbExclamation, "Stock Alert"
End If

rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing

Notes and cautions: adjust the connection string for your DB; avoid blocking the UI for long queries (use a background thread or show a progress indicator); for robust, always-on alerts use a scheduled server task or database job to send email/POs rather than relying on each client to run checks.

Recommended Answers

All 2 Replies

riched limit of the product

what does it sense?

You can create database with the columns:
1) product
2) minimun value
3) current value

Than you need to create procedure that will compare current value and minum value. If current value is equal or less then minimun value than send alert for the produvt that needs to be purchase.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.