VB Error

H

h3llz

The error must be the loop because Access just crashes when the loop is on, i
use the loop in other Subs, also productQuantity is 45.

Any suggestions?


Sub chkDelete_Click()
Dim Mydb As DAO.database
Dim QryDat As DAO.Recordset
Set Mydb = CurrentDb()

productID.SetFocus
productID = productID.Text
txtQuantity.SetFocus
DoCmd.RunSQL ("INSERT INTO tblProductsLog
(productID,quantity,[timestamp]) VALUES (" & productID & "," &
txtQuantity.Value & ",'" & Now() & "');")

Set QryDat = Mydb.OpenRecordset("SELECT quantity FROM
qryProductsWithQuantity WHERE productID=" & txtProductID.Caption & ";")
QryDat.MoveFirst
txtProductQuantity.Caption = QryDat.Fields.Item("quantity")
cmoSelectQuantity.RowSource = ""
i = "0"
productQuantity = txtProductQuantity.Caption
MsgBox productQuantity
Do While i <= productQuantity
cmoSelectQuantity.AddItem i
i = (i + 1)
Loop
cmoSelectQuantity.SetFocus
productQuantity = cmoSelectQuantity.Value
cmoSelectQuantity.Value = "0"

Form.Requery
Mydb.Close
Set Mydb = Nothing
Set QryDat = Nothing
End Sub
 
M

Maurice

and to top it of (as an addition to Dorian's reply) make sure you declare i so:

dim i as integer

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top