about delete

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 7
Reputation: denine is an unknown quantity at this point 
Solved Threads: 1
denine denine is offline Offline
Newbie Poster

about delete

 
0
  #1
Nov 14th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: about delete

 
0
  #2
Nov 14th, 2008
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
Last edited by QVeen72; Nov 14th, 2008 at 4:56 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 7
Reputation: denine is an unknown quantity at this point 
Solved Threads: 1
denine denine is offline Offline
Newbie Poster

Re: about delete

 
0
  #3
Nov 15th, 2008
Originally Posted by QVeen72 View Post
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
Attached Thumbnails
or2.JPG  
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: about delete

 
0
  #4
Nov 15th, 2008
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...
:
  1. If Grd.Row > 0 Then
  2. Grd.RemoveItem Grd.Row
  3. End If

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 7
Reputation: denine is an unknown quantity at this point 
Solved Threads: 1
denine denine is offline Offline
Newbie Poster

Re: about delete

 
0
  #5
Nov 17th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC