473,386 Members | 1,706 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,386 software developers and data experts.

RecordSet Update

Hi,

Im having a few problems with updating and deleting an item out of a recordset.
I have a list box in a main form that lists all the items in the table. When you click on one it comes up with a new form that displays all the details in text boxes for that record. You are able to edit the text and there is a edit and also a delete record button. When you click them though, the record doesnt update or delete the record that was being viewed but deletes the record previous.

Used the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdUpdate_Click()
  2.     rs.Edit
  3.       rs.Fields("FirstName") = TextBox(txtFirstName)
  4.       rs.Fields("LastName") = TextBox(txtLastName)
  5.       rs.Fields("Street") = TextBox(txtStreet)
  6.       rs.Fields("Suburb") = TextBox(txtSuburb)
  7.       rs.Fields("State") = TextBox(txtState)
  8.       rs.Fields("Postcode") = TextBox(5)
  9.       rs.Fields("PhoneNumber") = TextBox(txtPhoneNumber)
  10.       rs.Fields("MobileNumber") = TextBox(txtMobileNumber)
  11.       rs.Fields("Email") = TextBox(txtEmail)
  12.       rs.Fields("Birthday") = TextBox(txtBirthday)
  13.     rs.Update
  14.  
  15.     MsgBox ("Record Successfully Updated")
  16.  
  17. End Sub
  18.  
Thanks
Billybaub
Feb 6 '08 #1
3 4941
debasisdas
8,127 Expert 4TB
What is this TextBox in your code ?
Feb 6 '08 #2
VBWheaties
145 100+
Hi,

Im having a few problems with updating and deleting an item out of a recordset.
I have a list box in a main form that lists all the items in the table. When you click on one it comes up with a new form that displays all the details in text boxes for that record. You are able to edit the text and there is a edit and also a delete record button. When you click them though, the record doesnt update or delete the record that was being viewed but deletes the record previous.

Used the following code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdUpdate_Click()
  2.     rs.Edit
  3.       rs.Fields("FirstName") = TextBox(txtFirstName)
  4.       rs.Fields("LastName") = TextBox(txtLastName)
  5.       rs.Fields("Street") = TextBox(txtStreet)
  6.       rs.Fields("Suburb") = TextBox(txtSuburb)
  7.       rs.Fields("State") = TextBox(txtState)
  8.       rs.Fields("Postcode") = TextBox(5)
  9.       rs.Fields("PhoneNumber") = TextBox(txtPhoneNumber)
  10.       rs.Fields("MobileNumber") = TextBox(txtMobileNumber)
  11.       rs.Fields("Email") = TextBox(txtEmail)
  12.       rs.Fields("Birthday") = TextBox(txtBirthday)
  13.     rs.Update
  14.  
  15.     MsgBox ("Record Successfully Updated")
  16.  
  17. End Sub
  18.  
Thanks
Billybaub
Make sure the recordset is updateable. By Default, recordsets open as readonly. Programatically, it can be checked this way though you can easily see by viewing cursortype and locktype properties of your recordset object when you opened it:
Expand|Select|Wrap|Line Numbers
  1. If rs.supports(adUpdate) Then
  2.    msgbox "recordset is updateable."
  3. Else
  4.    msgbox "recordset is NOT updateable."
  5. End If
  6.  
Feb 7 '08 #3
werks
220 100+
Hi,

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdUpdate_Click()
  2.     rs.Edit
  3.       rs.Fields("FirstName") = TextBox(txtFirstName)
  4.       rs.Fields("LastName") = TextBox(txtLastName)
  5.       rs.Fields("Street") = TextBox(txtStreet)
  6.       rs.Fields("Suburb") = TextBox(txtSuburb)
  7.       rs.Fields("State") = TextBox(txtState)
  8.       rs.Fields("Postcode") = TextBox(5)
  9.       rs.Fields("PhoneNumber") = TextBox(txtPhoneNumber)
  10.       rs.Fields("MobileNumber") = TextBox(txtMobileNumber)
  11.       rs.Fields("Email") = TextBox(txtEmail)
  12.       rs.Fields("Birthday") = TextBox(txtBirthday)
  13.     rs.Update
  14.  
  15.     MsgBox ("Record Successfully Updated")
  16.  
  17. End Sub
  18.  
try this

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdUpdate_Click()
  2.     rs.Update 'try this code here
  3.       rs.Fields("FirstName") = TextBox(txtFirstName)
  4.       rs.Fields("LastName") = TextBox(txtLastName)
  5.       ....
  6.       ....
  7.       .....
  8.     rs.Update
  9.  
  10.     MsgBox ("Record Successfully Updated")
  11.  
  12. End Sub
  13.  
Feb 7 '08 #4

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

Similar topics

23
by: Rob Meade | last post by:
Lo all, Ok - this is what I was aiming to do, and then I thought - naahhh, that cant be right! query database results to recordset results to array using GetRows update values in one column...
4
by: Tom | last post by:
I want to open a recordset object on an .asp page. When I open the recordset I would like to use a stored procedure that expects a parameter to be passed for the stored procedure. I will then use...
0
by: belacyrf | last post by:
Here's the code: ------------------------------------------------------------------- accessID = request("accessID") strSQL = "SELECT * From PendingAccRequests Where AccessID = "&accessID ...
3
by: -Michelle- | last post by:
Hi Using A2003 on XP I am wondering from the MVP's and others, what is the most efficient way (in terms of time to process) of updating data in a table, using the docmd.RunSQL or Recordset ...
3
by: alex_peri | last post by:
Hello All, I am having problems with sorting a recordset by fields in Access. I have a table with three columns called ID, SNo and Time and would like to sort the records by Time. I would like to...
5
by: msprygada | last post by:
I am having a problem with getting a recordset to fill with data in an Access Data Project from a SQL Server database. Here is the code example that is in the Access help files that I can get to...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
5
by: zMisc | last post by:
Are there any tricks in updaitng a JOINed recordset? I joned to tables and when I try to change a field on the recordset and update it, I get this error: "Unknown column 'CCDE' in 'where...
1
by: sphinney | last post by:
All, I have a ADODB.Recordset in my Access 2002 project. I've been able to successfully add fields to the record set. According the the MS Access help files, I now must update the recordset to...
0
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.