Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Deleting records from DAO recordset

 
   Database Forums (Home) -> Visual Basic -> DAO RSS
Next:  Problem with 'Dim' ..... As Database ???  
Author Message
vonclausowitz

External


Since: Oct 03, 2005
Posts: 1



(Msg. 1) Posted: Sat Nov 04, 2006 12:55 am
Post subject: Deleting records from DAO recordset
Archived from groups: microsoft>public>vb>database>dao (more info?)

[posted earlier in other group]

Hi All,

I'm using the following code to delete one or more records from a DAO
recordset.
The code is working but I was wondering if I need to Update the
recordset with:

rsDel.Update?

Public Function DelRecs(Lstview As ListView, sEntity As String, sID As
String)

Dim I As Integer
Dim numSelected As Long
Dim itmX As ListItem
Dim rsDel As DAO.Recordset
Dim intResponse As Integer

Set rsDel = dbfASIC.OpenRecordset(sEntity, dbOpenDynaset)
numSelected = SendMessage(Lstview.hwnd, LVM_GETSELECTEDCOUNT, 0&, ByVal
0&)

If numSelected = 0 Then Exit Function

If numSelected > 0 Then
intResponse = MsgBox("Are you sure you want" & Chr$(13) & _
"to remove " & numSelected & " record(s)?", vbYesNo,
"Warning")
If intResponse = vbYes Then
For I = 1 To Lstview.ListItems.Count
If Lstview.ListItems(I).Selected Then
Lstview.ListItems(I).Selected = True
Set itmX = Lstview.SelectedItem
rsDel.FindFirst sID & " = " & Mid(itmX.Key, 2)
rsDel.Delete
End If
Next I
Call RemoveUnUsedLinks(sEntity, str(Mid(itmX.Key, 2)))
End If
End If

End Function

Marco

 >> Stay informed about: Deleting records from DAO recordset 
Back to top
Login to vote
Ralph

External


Since: Jun 25, 2005
Posts: 348



(Msg. 2) Posted: Sat Nov 04, 2006 6:57 am
Post subject: Re: Deleting records from DAO recordset [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

wrote in message

> [posted earlier in other group]
>
> Hi All,
>
> I'm using the following code to delete one or more records from a DAO
> recordset.
> The code is working but I was wondering if I need to Update the
> recordset with:
>
> rsDel.Update?
>
> Public Function DelRecs(Lstview As ListView, sEntity As String, sID As
> String)
>
> Dim I As Integer
> Dim numSelected As Long
> Dim itmX As ListItem
> Dim rsDel As DAO.Recordset
> Dim intResponse As Integer
>
> Set rsDel = dbfASIC.OpenRecordset(sEntity, dbOpenDynaset)
> numSelected = SendMessage(Lstview.hwnd, LVM_GETSELECTEDCOUNT, 0&, ByVal
> 0&)
>
> If numSelected = 0 Then Exit Function
>
> If numSelected > 0 Then
> intResponse = MsgBox("Are you sure you want" & Chr$(13) & _
> "to remove " & numSelected & " record(s)?", vbYesNo,
> "Warning")
> If intResponse = vbYes Then
> For I = 1 To Lstview.ListItems.Count
> If Lstview.ListItems(I).Selected Then
> Lstview.ListItems(I).Selected = True
> Set itmX = Lstview.SelectedItem
> rsDel.FindFirst sID & " = " & Mid(itmX.Key, 2)
> rsDel.Delete
> End If
> Next I
> Call RemoveUnUsedLinks(sEntity, str(Mid(itmX.Key, 2)))
> End If
> End If
>
> End Function
>
> Marco
>

NO!

Do not call Update. You call it for AddNew and Edit, but never delete.

-ralph

 >> Stay informed about: Deleting records from DAO recordset 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
dao recordset error trapping - I have a dao recordset which I update with the following code: With rsOrderShip .Edit !CustCode = frmOrders.txtSTCustCode.Text !stcustname = frmOrders.txtSTCustName.Text !staddress1 = frmOrders.txtSTAddress1.Text ....

Error 3167 recordset is delete - Hello, ich habe in verschiedenen Newsgroups gesucht aber keine Lösung zu dem folgenden Problem gefunden. Zwei Personen arbeiten gemeinsam mit einem VB6-Programm an einer ACCESS 2000 Datenbank Der Zugriff von VB auf ACCESS erfolgt mit DAO 3.60. Eine de...

ADOR.RecordSet and Vista - I've inherited two sets of VB6 based com components from another developer. A set of client side activeX controls and a set of server side com controls. Basically, browser activated client side activex controls invokes server side control on Windows....

Updating DAO Record Moves it to the End of the Recordset - I am trying to loop through a DAO recordset and replace characters as needed. However, when the replacement consists of just appending a character, the first record in the recordset seems to move to the end of the recordset after the first iteration..

Problem with Data1.recordset.AddNew - Hi All I have a Access97 Database and if I delete all the records compat the database when I use AddNew I get an error message Runtime Error '3426': This action was cancelled by an arseociated object. and highlights the Data1.recodset.AddNew line in..
   Database Forums (Home) -> Visual Basic -> DAO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]