473,809 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting curent record

Hi all, can anyone tell me how to delete just the current record

if tempdate >= todaydate then
Set newMail=Server. CreateObject("C DONTS.newMail")
newMail.to = rs.fields("Emai l")
newMail.From = "in**@someone.b iz"
newMail.Subject = "Wavestatio n Present Planner"
newMail.Body = "Dear " & rs.fields("qNam e") & vbcrlf & vbcrlf & "This is
your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Peri od") & " before " & rs.fields("qpNa me") & "'s birthday
which falls on " & rs.fields("qDat e") & "." & vbcrlf & vbcrlf & "Your
message: " & rs.fields("Mess age") & vbcrlf & vbcrlf & "Regards" & vbcrlf
& vbcrlf & "The Wavestation Team."
newMail.Send

conn.Execute "DELETE FROM Bmemo" <-------------------- ?????????
end if
rs.movenext
many thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003
Jul 19 '05 #1
8 2372
Is there a primary key in your table? If so, you can say

conn.execute("D ELETE Bmemo WHERE [primaryKeyColum n] = " &
rs("primaryKeyC olumn"))

Though I seriously question your methodology here... you're sending an
e-mail out within every iteration of your recordset loop? There are more
efficient ways to do this...

"xool" <me@memail.ne t> wrote in message
news:OW******** ******@TK2MSFTN GP10.phx.gbl...
Hi all, can anyone tell me how to delete just the current record

if tempdate >= todaydate then
Set newMail=Server. CreateObject("C DONTS.newMail")
newMail.to = rs.fields("Emai l")
newMail.From = "in**@someone.b iz"
newMail.Subject = "Wavestatio n Present Planner"
newMail.Body = "Dear " & rs.fields("qNam e") & vbcrlf & vbcrlf & "This is your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Peri od") & " before " & rs.fields("qpNa me") & "'s birthday
which falls on " & rs.fields("qDat e") & "." & vbcrlf & vbcrlf & "Your
message: " & rs.fields("Mess age") & vbcrlf & vbcrlf & "Regards" & vbcrlf & vbcrlf & "The Wavestation Team."
newMail.Send

conn.Execute "DELETE FROM Bmemo" <-------------------- ?????????
end if
rs.movenext
many thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003

Jul 19 '05 #2
Do you have an ID field, or a field or group of fields that define a
unique row? Get that out of the recordset, close it, and then delete
where that field = that value.

"xool" <me@memail.ne t> wrote in message
news:OW******** ******@TK2MSFTN GP10.phx.gbl...
Hi all, can anyone tell me how to delete just the current record

if tempdate >= todaydate then
Set newMail=Server. CreateObject("C DONTS.newMail")
newMail.to = rs.fields("Emai l")
newMail.From = "in**@someone.b iz"
newMail.Subject = "Wavestatio n Present Planner"
newMail.Body = "Dear " & rs.fields("qNam e") & vbcrlf & vbcrlf & "This is your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Peri od") & " before " & rs.fields("qpNa me") & "'s birthday which falls on " & rs.fields("qDat e") & "." & vbcrlf & vbcrlf & "Your
message: " & rs.fields("Mess age") & vbcrlf & vbcrlf & "Regards" & vbcrlf & vbcrlf & "The Wavestation Team."
newMail.Send

conn.Execute "DELETE FROM Bmemo" <-------------------- ?????????
end if
rs.movenext
many thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003

Jul 19 '05 #3
Hi, no I don't have an ID field, any way of just deleting the current row?

"Kris Eiben" <ei************ *********@yahoo .com> wrote in message
news:O$******** ******@tk2msftn gp13.phx.gbl...
Do you have an ID field, or a field or group of fields that define a
unique row? Get that out of the recordset, close it, and then delete
where that field = that value.

"xool" <me@memail.ne t> wrote in message
news:OW******** ******@TK2MSFTN GP10.phx.gbl...
Hi all, can anyone tell me how to delete just the current record

if tempdate >= todaydate then
Set newMail=Server. CreateObject("C DONTS.newMail")
newMail.to = rs.fields("Emai l")
newMail.From = "in**@someone.b iz"
newMail.Subject = "Wavestatio n Present Planner"
newMail.Body = "Dear " & rs.fields("qNam e") & vbcrlf & vbcrlf &

"This is
your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Peri od") & " before " & rs.fields("qpNa me") & "'s

birthday
which falls on " & rs.fields("qDat e") & "." & vbcrlf & vbcrlf & "Your
message: " & rs.fields("Mess age") & vbcrlf & vbcrlf & "Regards" &

vbcrlf
& vbcrlf & "The Wavestation Team."
newMail.Send

conn.Execute "DELETE FROM Bmemo" <-------------------- ?????????
end if
rs.movenext
many thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003
Jul 19 '05 #4
> Hi, no I don't have an ID field, any way of just deleting the current row?

If you don't have a way to uniquely identify a single row, no. This is one
of the reasons a primary key is an essential part of any sane table design.
Jul 19 '05 #5
Eegs

How about instead of trying to do that, execute one DELETE query after your
loop is finished and use the same WHERE clause that you used to create the
recordset? Of course, if a new record is inserted during this loop, that'll
get deleted, but if you're using timestamps or anything, you could add the
current date and time onto your WHERE clause in DELETE where the time would
be set at the time your first recordset is created. Does this make sense?
Example:

(Assuming SQL)
Set rs = objADO.Execute( "SELECT GETDATE(),
[email],[qpName],[qDate],[Message],[Period] FROM [Bmemo] WHERE
[Something]='a value'")
sTime = rs.fields.item( 0).value
'''your looping code here
rs.Close
Set rs = Nothing

objADO.Execute "DELETE FROM [Bmemo] WHERE [Something]='a value' AND
[DateAddedToTheD atabase]<='" & sTime & "'"

Ray at work

"xool" <me@memail.ne t> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi, no I don't have an ID field, any way of just deleting the current row?

"Kris Eiben" <ei************ *********@yahoo .com> wrote in message
news:O$******** ******@tk2msftn gp13.phx.gbl...
Do you have an ID field, or a field or group of fields that define a
unique row? Get that out of the recordset, close it, and then delete
where that field = that value.

"xool" <me@memail.ne t> wrote in message
news:OW******** ******@TK2MSFTN GP10.phx.gbl...
Hi all, can anyone tell me how to delete just the current record

if tempdate >= todaydate then
Set newMail=Server. CreateObject("C DONTS.newMail")
newMail.to = rs.fields("Emai l")
newMail.From = "in**@someone.b iz"
newMail.Subject = "Wavestatio n Present Planner"
newMail.Body = "Dear " & rs.fields("qNam e") & vbcrlf & vbcrlf &

"This is
your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Peri od") & " before " & rs.fields("qpNa me") & "'s

birthday
which falls on " & rs.fields("qDat e") & "." & vbcrlf & vbcrlf & "Your
message: " & rs.fields("Mess age") & vbcrlf & vbcrlf & "Regards" &

vbcrlf
& vbcrlf & "The Wavestation Team."
newMail.Send

conn.Execute "DELETE FROM Bmemo" <-------------------- ?????????
end if
rs.movenext
many thanks

Jul 19 '05 #6
No, afaik there is no way to delete a row as you loop through it,
somehow knowing which row you're on just because it's "current." (I'm
sure someone will correct me if I'm wrong -- Aaron, Ray, I'm looking in
your general direction.) You have to be able to somehow identify the
row from the data in the row.

So, you don't have an ID field. Surely, though, you have some kind of
check in place to keep users from entering duplicate data -- use the
fields you check there. If you don't have such a check in place, it's
time to put one in.

"xool" <me@memail.ne t> wrote in message
news:#V******** ******@TK2MSFTN GP10.phx.gbl...
Hi, no I don't have an ID field, any way of just deleting the current row?
"Kris Eiben" <ei************ *********@yahoo .com> wrote in message
news:O$******** ******@tk2msftn gp13.phx.gbl...
Do you have an ID field, or a field or group of fields that define a
unique row? Get that out of the recordset, close it, and then delete where that field = that value.

"xool" <me@memail.ne t> wrote in message
news:OW******** ******@TK2MSFTN GP10.phx.gbl...
Hi all, can anyone tell me how to delete just the current record

if tempdate >= todaydate then
Set newMail=Server. CreateObject("C DONTS.newMail")
newMail.to = rs.fields("Emai l")
newMail.From = "in**@someone.b iz"
newMail.Subject = "Wavestatio n Present Planner"
newMail.Body = "Dear " & rs.fields("qNam e") & vbcrlf & vbcrlf &
"This is
your present planner reminder." & vbcrlf & vbcrlf & "It's " &
rs.fields("Peri od") & " before " & rs.fields("qpNa me") & "'s

birthday
which falls on " & rs.fields("qDat e") & "." & vbcrlf & vbcrlf &
"Your message: " & rs.fields("Mess age") & vbcrlf & vbcrlf & "Regards" & vbcrlf
& vbcrlf & "The Wavestation Team."
newMail.Send

conn.Execute "DELETE FROM Bmemo" <--------------------

????????? end if
rs.movenext
many thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 02/09/2003

Jul 19 '05 #7
> No, afaik there is no way to delete a row as you loop through it,
somehow knowing which row you're on just because it's "current." (I'm
sure someone will correct me if I'm wrong -- Aaron, Ray, I'm looking in
your general direction.)
Well, there might be a way to use rs.delete in this case, but I'm sure it is
RDBMS-implementation-specific. For example, in SQL Server, you should get
an "insufficie nt key information" error, because rs.delete translates to a
DELETE statement, and without a key, there is no way to know which row(s)
the delete statement applies to.
So, you don't have an ID field. Surely, though, you have some kind of
check in place to keep users from entering duplicate data -- use the
fields you check there. If you don't have such a check in place, it's
time to put one in.


Agreed. Or, if duplicates are okay, at least have a surrogate key (like
IDENTITY/AUTOINCREMENT) to feign sequence. Sometimes the only unique part
about a row might be, for example, the body of an e-mail message, in an
NTEXT column. You don't want to use that to identify a row. :-)
Jul 19 '05 #8
Ok, thanks all. I've decided to approach it a different way, just stuck with
a data type mismatch now if any one can help (see new thread)

many thanks
"Aaron Bertrand - MVP" <aa***@TRASHasp faq.com> wrote in message
news:u2******** ******@TK2MSFTN GP11.phx.gbl...
No, afaik there is no way to delete a row as you loop through it,
somehow knowing which row you're on just because it's "current." (I'm
sure someone will correct me if I'm wrong -- Aaron, Ray, I'm looking in
your general direction.)
Well, there might be a way to use rs.delete in this case, but I'm sure it

is RDBMS-implementation-specific. For example, in SQL Server, you should get
an "insufficie nt key information" error, because rs.delete translates to a
DELETE statement, and without a key, there is no way to know which row(s)
the delete statement applies to.
So, you don't have an ID field. Surely, though, you have some kind of
check in place to keep users from entering duplicate data -- use the
fields you check there. If you don't have such a check in place, it's
time to put one in.


Agreed. Or, if duplicates are okay, at least have a surrogate key (like
IDENTITY/AUTOINCREMENT) to feign sequence. Sometimes the only unique part
about a row might be, for example, the body of an e-mail message, in an
NTEXT column. You don't want to use that to identify a row. :-)

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 01/09/2003
Jul 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
485
by: xool | last post by:
Hi all, can anyone tell me how to delete just the current record if tempdate >= todaydate then Set newMail=Server.CreateObject("CDONTS.newMail") newMail.to = rs.fields("Email") newMail.From = "info@someone.biz" newMail.Subject = "Wavestation Present Planner" newMail.Body = "Dear " & rs.fields("qName") & vbcrlf & vbcrlf & "This is your present planner reminder." & vbcrlf & vbcrlf & "It's " & rs.fields("Period") & " before " &...
1
6122
by: Mark | last post by:
This question refers to a main form with a continuous form subform. After an error occurs after entering several records in the subform, how can I delete all the data in the main form and all the records in the subform? I have tried undoing both the main form and the subform and I have tried deleting the record in the main form. Thanks! Mark
3
2758
by: Nathan Bloom | last post by:
Hi, I have a data entry form (access 2000) that also allows the user to add, update, and delete records from the form. The Delete action is carried out in an event procedure and has the following code: Private Sub Command28_Click() On Error GoTo Err_Command28_Click
2
1903
by: uv | last post by:
Hi! I'm having problems submitting a new record through the form. I'm working with the wizard and I've added a control button to my form for entering entering a new record but for some reason it only works for the first record I enter. The same goes for deleting a record. It says I can't access the records, and that goes for both making or deleting. I'd appreciate your help very much, uv
1
2400
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting about 80 records from the Orders table. 80 out of a 1000 records. Now our data entry form shows our customer addresses, but not customer order history. When looking at all of the tables, customer, payments, orders, they still have all of the...
46
4442
by: DP | last post by:
hi, i've got a form, with a subform in it. i've got a delete button in the subform. the code i;ve got is; Private Sub cmdDeleteRecord_Click() msg = "Are you sure you want to delete this film rental record?" Style = vbYesNo + vbQuestion + vbDefaultButton2
19
2153
by: MaXX | last post by:
Hi, I hope I'm not OT. I have the following issue: I want to delete a record from my db with a php script. Let's say I'm auth'd and I want to delete the record id 440. With a simple form (get or post), I send the id to my script and delete the record (DELETE FROM table WHERE id=some_validated_input). The problem is if I'm a nasty guy I just write my own form and delete any
4
2400
by: sphinney | last post by:
I'm not exactly sure how to start this post. My question is pretty simple, but it will take a little bit of context before I can state it. (And thanks in advance for taking the time to read this!) Context: What I'm essentially trying to do is create a poor man's document imaging system in Access 2007. I have a database that contains forms and modules (but no data) that I'm going to distribute to 200+ users in my company that have limited...
1
1774
by: Kyosuke18 | last post by:
Hi everyone, I have a problem in deleting a data that is connected on the database.. I tried this code but it shows me an error: Run-time error '-2147217900(80040e14)': Syntax error in string in query expression 'ID=". Here is the code that i did: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim ab As String cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.