473,396 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

deleting a row value

553 512MB
If i want to delete a record from a table , i use the following code:

Expand|Select|Wrap|Line Numbers
  1. Dim rst As DAO.Recordset
  2. Dim db As DAO.Database
  3.  
  4. Set db = CurrentDb
  5.  
  6. Set rst = db.OpenRecordset("Select name FROM Table1 WHERE name='" & "name1" & "'")
  7.  
  8. rst.Edit
  9. rst.Fields("name") = "name2"
  10. rst.Delete
  11.  
It works. My question is how can i delete a particular field value of a record?

For example: Table1 contains
Name Age
-----------------
Name1 10
Name2 20 --- If i want to delete only 20 not the whole row , how can
it be done ?

2) Also, when i open a RecordSet for delete or update purposes only, why still do i have to write a SELECT statement like above ? Are there any other simple methods out there?
Jul 25 '07 #1
3 1343
missinglinq
3,532 Expert 2GB
You have posted your question in the Articles section rather than the Forum section.

I have moved it across for you.

Linq
Jul 25 '07 #2
JKing
1,206 Expert 1GB
I think you want an update query rather than a delete query.

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblPerson SET age = Null
  2. WHERE name = 'Jared'
  3.  
You don't need an open recordset to do this either. You can simply use the Docmd.RunSQL command.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_Click()
  2.  
  3. Dim strSQL As String
  4.  
  5. strSQL = "UPDATE tblPerson SET age = Null WHERE name = 'Jared'"
  6.  
  7. Docmd.RunSQL strSQL
  8. End Sub
  9.  
There are many other ways to manipulate recordsets and you can open tables directly or even open saved queries. I suggest taking a look at the available methods of a recordset and the examples for them provided in the help files.
Jul 25 '07 #3
nico5038
3,080 Expert 2GB
Or even shorter:
Expand|Select|Wrap|Line Numbers
  1. currentdb.execute ("UPDATE tblPerson SET age = Null WHERE name = 'Jared'")
  2.  
Nic;o)
Jul 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Rick | last post by:
Hi, Does deleting an object more than one times incur undefined behavior? I think it doesn't but just making sure... thanks Rick
6
by: Abhijeet | last post by:
I was just toying around idea of deleting this from a member function. Was expecting that any acess to member variable or function after deleting sould give me dump(segmetation violation).Cause now...
3
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...
1
by: jez123456 | last post by:
Hi, I have a windows form with a listbox control. My code all works correctly when deleting an item from the listbox except the last item. I get the following message when trying to delete the...
46
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...
51
by: Joe Van Dyk | last post by:
When you delete a pointer, you should set it to NULL, right? Joe
1
by: tsuki | last post by:
Hello, I have a problem concerning DOM and XML. The structure of my xml is the following: <?xml version="1.0" encoding="utf-8"?> <website> <language1> <seite> <bereich1>
2
by: azmiza | last post by:
Hi everybody, I need your help. I want to view my sql database and its work very well which is display in my web browser but once I want to press button yes, its not working, I check the...
13
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
2
Parul Bagadia
by: Parul Bagadia | last post by:
I have written a code for deleting certain value from linklist; it's not working; where as i have written one for deleting a no., after given no. which works fine! I even debugged it; but invain;...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.