Try Dim i as integer i = 0 ' not i = "0"
-Dorian
"h3llz" wrote:
[Quoted Text] > 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
|