| | |
about delete
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 7
Reputation:
Solved Threads: 1
hi good day, im a beginner of VB using DAO. Right now im doing my first sales system. My problem is I want to delete something from my database. my code is this.
With DTPicker1
Dbase.Execute(Delete * from SalesTable where eDate = ' " & DTPicker1.Value & " ' ")
End With
Unfortunately this code doesn't work. it gives run-time error "3464".
Anybody can help me.
With DTPicker1
Dbase.Execute(Delete * from SalesTable where eDate = ' " & DTPicker1.Value & " ' ")
End With
Unfortunately this code doesn't work. it gives run-time error "3464".
Anybody can help me.
•
•
Join Date: Nov 2008
Posts: 7
Reputation:
Solved Threads: 1
•
•
•
•
Hi,
Try This :
Dbase.Execute(Delete * from SalesTable where eDate = #" _
& Format(DTPicker1.Value,"dd-mm-yyyy") & "#")
OR
Dbase.Execute(Delete * from SalesTable where eDate = CDate('" _
& Format(DTPicker1.Value,"dd-mm-yyyy") & "')")
Regards
Veena
thank you veena for your help. it really helps me a lot on my project. if it is ok for you to ask another help about delete?
this is my problem. I have already an existing data on the database. If i were going to view the existing data it will display on the flexgrid. Now, i want to delete some data on the flex grid, unfortunately all having the same ProdCode will be deleted.
How will i going to delete the data on the database with only the highlighted data only found in the flex grid?
This is my code but it doesn't work and my UI.
Private Sub cmdDelete_Click()
Dim i As Integer
With Me.grd
Dbase.Execute ("Delete * from OrderTable where TransCode ='" & .TextMatrix(.Row, 0) & "'")
End With
With Me.grd
Dbase.Execute ("Delete * from PaymentTable where TransCode ='" & .TextMatrix(.Row, 0) & "'")
End With
With Me.grd
i = .Row
If i > 0 Then
While i < .Rows
If i < .Rows - 1 Then
.TextMatrix(i, 0) = .TextMatrix(i + 1, 0)
.TextMatrix(i, 1) = .TextMatrix(i + 1, 1)
.TextMatrix(i, 2) = .TextMatrix(i + 1, 2)
.TextMatrix(i, 3) = .TextMatrix(i + 1, 3)
.TextMatrix(i, 4) = .TextMatrix(i + 1, 4)
.TextMatrix(i, 5) = .TextMatrix(i + 1, 5)
i = i + 1
Else
.Rows = .Rows - 1
End If
Wend
End If
End With
OT.MoveFirst
Do Until OT.EOF
With OT
.Edit
!Amount = lblGrnTotal.Caption
.Update
End With
OT.MoveNext
Loop
PAY.MoveFirst
Do Until PAY.EOF
With PAY
.Edit
!Amount = lblGrnTotal.Caption
.Update
End With
PAY.MoveNext
Loop
Load Form16
Form16.Show
End Sub
regards;
Denine
Hi,
You need 2 Conditions in The Delete Statement :
"Delete * from OrderTable where ProdCode ='" & .TextMatrix(.Row, 0) & "' And TransCode=" Val(txtTransNo.Text)
If ProdCode Is Numeric, then Remove the Single Quotes..
After Deleting From Database, you need to Remove the Row From the Grid As well...
:
Regards
Veena
You need 2 Conditions in The Delete Statement :
"Delete * from OrderTable where ProdCode ='" & .TextMatrix(.Row, 0) & "' And TransCode=" Val(txtTransNo.Text)
If ProdCode Is Numeric, then Remove the Single Quotes..
After Deleting From Database, you need to Remove the Row From the Grid As well...
:
vb Syntax (Toggle Plain Text)
If Grd.Row > 0 Then Grd.RemoveItem Grd.Row End If
Regards
Veena
•
•
Join Date: Nov 2008
Posts: 7
Reputation:
Solved Threads: 1
Hi Veena once again thank you so much for your help. The code that you gave me works on my project. Here's another problem on my code, I hope you can still help me. It is all about in my counter and in my total sales.
The Code of my counter that I make doesn't work again and also in displaying the total sales in descending order. This is my code.
-----------------------------------------------------------------
counter
For i = 1 To grd.Rows - 1
With INV
If grd.TextMatrix(i, 0) = INV!ProdCode Then
.Edit
!Quantity = !Quantity + Val(grd.TextMatrix(i, 3))
.Update
Else
.AddNew
!ProdCode = grd.TextMatrix(i, 0)
!ProdName = grd.TextMatrix(i, 2)
!Quantity = grd.TextMatrix(i, 3)
!Date = DTPicker1.Value
.Update
End If
End With
Next i
---------------------------------------------------------------------------------------
Display the Total Sale in descending order
Set SH = Dbase.OpenRecordset("Select * from SalesHeader where iDate <= cDate (' " & CStr(DTPicker1.Value) & " ') and iDate >= cDate(' " & CStr(DTPicker2.Value) & " ')Order by cDate Desc ")
----------------------------------------------------------------------------
Regards
Denine
The Code of my counter that I make doesn't work again and also in displaying the total sales in descending order. This is my code.
-----------------------------------------------------------------
counter
For i = 1 To grd.Rows - 1
With INV
If grd.TextMatrix(i, 0) = INV!ProdCode Then
.Edit
!Quantity = !Quantity + Val(grd.TextMatrix(i, 3))
.Update
Else
.AddNew
!ProdCode = grd.TextMatrix(i, 0)
!ProdName = grd.TextMatrix(i, 2)
!Quantity = grd.TextMatrix(i, 3)
!Date = DTPicker1.Value
.Update
End If
End With
Next i
---------------------------------------------------------------------------------------
Display the Total Sale in descending order
Set SH = Dbase.OpenRecordset("Select * from SalesHeader where iDate <= cDate (' " & CStr(DTPicker1.Value) & " ') and iDate >= cDate(' " & CStr(DTPicker2.Value) & " ')Order by cDate Desc ")
----------------------------------------------------------------------------
Regards
Denine
![]() |
Similar Threads
- Cannot delete file (Windows 95 / 98 / Me)
- can't delete cache (Web Browsers)
- cannot delete shortcut (Windows 95 / 98 / Me)
- Can't delete a folder (Windows NT / 2000 / XP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Help getting txt value from Word selection.copy
- Next Thread: voice recognition system>HELP
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection copy creat ctrl+f data database datareport date delete dissertations dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





