Private Sub Form_Load()
Dim sVal$, StartNo&
Dim rst As DAO.Recordset
CurrentDb.Execute "DELETE * FROM Temp_Quotation"
sVal = "INSERT INTO Temp_Quotation ( RbSize, TTID, Qty, S_Curr, Grade ) " & vbCrLf & _
"SELECT RbSize, 3 AS TTID, '-' AS Qty, 1 AS S_Curr, '500B' AS Grade " & vbCrLf & _
"FROM usysRbStdSize"
CurrentDb.Execute sVal
'Setting unique record ID in the "Temp_Quotation" table
Set rst = CurrentDb.OpenRecordset("Temp_Quotation", dbOpenDynaset)
With rst
Do Until .EOF = True
StartNo = StartNo + 1
.Edit
!RecID = StartNo
.Update
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
Me.frmRbQuotation_Sub.Form.Requery
End Sub
Private Sub Btn_Delete_Click()
Dim I As Integer, sVal$
If LineNo = 0 Then MsgBox "No Record Selected !": Exit Sub
If MsgBox("Confirm Delete " & LineNo & " Sizes ?", vbQuestion + vbDefaultButton2 + vbYesNo, "Confirm Delete") = vbYes Then
Me.frmRbQuotation_Sub.Form.AllowAdditions = False
For I = TopLine To LineNo + TopLine - 1
Me.frmRbQuotation_Sub.Form.SelTop = I
' Wrong way:
' DoCmd.SetWarnings False
' Me.frmRbQuotation_Sub.SetFocus
' RunCommand acCmdDeleteRecord
' DoCmd.SetWarnings True
sVal = sVal & ", " & Me.frmRbQuotation_Sub.Form!RecID
Next
End If
If Len(sVal) > 2 Then
sVal = Mid(sVal, 3)
'Deleting selected records :
sVal = "DELETE * FROM Temp_Quotation WHERE RecID IN (" & sVal & ")"
CurrentDb.Execute sVal
Me.frmRbQuotation_Sub.Form.Requery
End If
TopLine = 0
LineNo = 0
End Sub