|
-
Oct 13th, 2000, 09:27 PM
#1
Thread Starter
New Member
pls help.....
i m doing a inventory system...using vb6, and ms access(for database)now my prb is donno how to delete certain data form database...
for example..... i got these stocks ...
A001
A002
A003
A004
A005
if i want to delete only from A002 to A004
and left A001 and A005 in database
how m i code this ....
******************************************************
Private Sub cmdDel_Click()
Dim DB As Database
Dim rec As Recordset
Dim reply
Dim f1 As String
Set DB = OpenDatabase("c:\inventory system\Inven.mdb")
Set rec = DB.OpenRecordset("Sales")
reply = MsgBox("Delete from " & cbStockCodeFrom & " until " & cbStockCodeTo & " ? ", vbYesNoCancel)
If reply = vbYes Then
Do
If f1 = ("{Sales.StockCode} >= " & cbStockCodeFrom.Text & _
" and {Sales.StockCode} <= " & cbStockCodeTo.Text & "") Then
rec.Delete
rec.MoveNext
If rec.EOF Then Exit Sub
End If
Loop
MsgBox ("Record is Deleted")
End If
End Sub
**************************************************
this is wat i have done so far...
i keep changing the code...until i got blur wat m i doing now...
i really need some help....
thankss alottt
swiss
-
Oct 13th, 2000, 10:21 PM
#2
Fanatic Member
Hi Swiss, Try This :)
Code:
Private Sub cmdDel_Click()
Dim DB As Database
Dim reply As Integer
Set DB = OpenDatabase("c:\inventory system\Inven.mdb")
reply = MsgBox("Delete from " & cbStockCodeFrom & " until " & cbStockCodeTo & " ? ", vbYesNoCancel)
If reply = vbYes Then
DB.Execute "DELETE FROM Sales WHERE Sales.StockCode >= '" & cboStockCodeFrom.Text & "' AND Sales.StockCode <= '" & cboStockCodeTo.Text & "'"
MsgBox ("Record is Deleted")
End If
End Sub
All the best.
-
Oct 13th, 2000, 10:26 PM
#3
Try this:
Code:
Private Sub cmdDel_Click()
Dim DB As Database
Dim rec As Recordset
Dim reply
Dim f1 As String
Set DB = OpenDatabase("c:\inventory system\Inven.mdb")
Set rec = DB.OpenRecordset("Sales")
reply = MsgBox("Delete from " & cbStockCodeFrom
& "until " & cbStockCodeTo & " ? ",
vbYesNoCancel)
If reply = vbYes Then
DB.Execute "DELETE FROM Sales WHERE StockCode BETWEEN '" _
& cbStockCodeFrom.Text & "' AND '" _
& cbStockCodeTo.Text & "'", dbFailOnError
End If
MsgBox ("Record is Deleted")
End Sub
"It's cold gin time again ..."
Check out my website here.
-
Oct 15th, 2000, 08:12 PM
#4
Thread Starter
New Member
hi... thanks guys... and i have successfully solve my prb now...
yup thr is another prb ... is regarding to display crystal report....means... how to get the crystal report display the selected records??
ex...
i only select the A002, A003 and A004 to be display
and this is my code...
thanks
swiss
********************************************************
Private Sub cmdPrint_Click()
Dim sCondition, sTemp As String
sCondition = ""
sTemp = ""
mOK = True
If optSpecificStockCode.Value = True Then
sTemp = ("{stocktake.StockCode} >= " & cbStockCodeFrom.Text & _
" and {stocktake.StockCode} >= " & cbStockCodeTo.Text & "")
If sCondition = "" Then
sCondition = sTemp
Else
sCondition = sCondition & " and " & sTemp
End If
End If
If optPreview.Value = True Then
mDestination = crptToWindow
Else
mDestination = crptToPrinter
End If
Debug.Print "f=" & sCondition
With rpt
.Reset
.DataFiles(0) = (App.Path & "\Inven.mdb")
.ReportFileName = (App.Path & "\rptst.rpt")
.WindowTitle = "Stock Take Report"
.WindowState = crptMaximized
.WindowShowRefreshBtn = True
.SelectionFormula = sCondition
.Destination = ToDestination
If .PrintReport() <> 0 Then
MsgBox "Error #: " & .LastErrorNumber & vbCrLf & .LastErrorString
End If
End With
End Sub
**********************************************
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|