943,891 Members | Top Members by Rank

Ad:
Nov 14th, 2008
0

about delete

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
denine is offline Offline
7 posts
since Nov 2008
Nov 14th, 2008
0

Re: about delete

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.
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Nov 15th, 2008
0

Re: about delete

Click to Expand / Collapse  Quote originally posted by QVeen72 ...
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
Click image for larger version

Name:	or2.JPG
Views:	10
Size:	65.6 KB
ID:	8158  
Reputation Points: 10
Solved Threads: 1
Newbie Poster
denine is offline Offline
7 posts
since Nov 2008
Nov 15th, 2008
0

Re: about delete

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...
:
vb Syntax (Toggle Plain Text)
  1. If Grd.Row > 0 Then
  2. Grd.RemoveItem Grd.Row
  3. End If

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Nov 17th, 2008
0

Re: about delete

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
denine is offline Offline
7 posts
since Nov 2008
Jul 7th, 2011
0

Code to delete all records in the database using vb6.0

hi, am fred
am designing a simple program of telephone directory using vb6.0, i would like to get a code
that deletes all the contents in the database. help me please am stuck. I have tried the one below and it refused, it only deletes one record in the database. thanks.

Private Sub Command2_Click()
Dim imessage As Integer
imessage = MsgBox(" are you sure you want to delete this record?", vbYesNoCancel + vbQuestion)
If imessage = vbYes Then
Data1.Recordset.Delete
Data1.Recordset.MoveNext
End If
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fredkajubi is offline Offline
1 posts
since Jul 2011
Jul 7th, 2011
0
Re: about delete
You are hijacking someone else's thread Fred. Please start your own.
Reputation Points: 88
Solved Threads: 62
Posting Whiz
ChrisPadgham is offline Offline
323 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Storing and Retrieving document from database
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Help needed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC