If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > MS Access Help Please

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-04, 08:19
nickaz nickaz is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
MS Access Help Please

Hi,
Im trying to update a row on my database using input from text fields. Ive managed to get the values into variables, but when I try and update the row it either doesnt do what im expecting or has comile errors.

The code is....

'create a recordset variable (array)
Dim unitsdata As Recordset

'set that array to be a row in the database
Set unitsdata = CurrentDb.OpenRecordset("Booking")

'add a new row to the database
unitsdata.AddNew

'populate the array with values
unitsdata!JobNumber = DataValue1 And ActivityCd = DataValue3 And BookingDate = DataValue4 And JobDescription = DataValue6 And HangerId = DataValue7 And ShopId = DataValue8

'update the row in question
unitsdata.Update


I had it working last night with one value but I need the whole row updated!
Can anyone help please?
Reply With Quote
  #2 (permalink)  
Old 12-14-04, 03:09
DerrickM DerrickM is offline
Registered User
 
Join Date: Nov 2004
Posts: 32
Smile

Just a suggestion. Try:

'populate the array with values
unitsdata!JobNumber = DataValue1
ActivityCd = DataValue3
BookingDate = DataValue4
JobDescription = DataValue6
HangerId = DataValue7
ShopId = DataValue8

But I suspect I'm missing something obvious. Try testing each variable for a null value or zero length string before putting it into a field.
Reply With Quote
  #3 (permalink)  
Old 12-14-04, 03:34
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,264
Hi Nickaz
you may get a better response on the Access forum in this site
if you are going to update a record using your method then you first off need to locate the record in the recordset, then apply the changes, then update the record. Your code is trying to add a record
DerrickM's response is fine, except he hasn't topped &tailed it

with untsdata 'populate the array with values
.addnew
!JobNumber = DataValue1
!ActivityCd = DataValue3
!BookingDate = DataValue4
!JobDescription = DataValue6
!HangerId = DataValue7
!ShopId = DataValue8
unitsdata.Update 'update the row in question
end with

you could do the same task with an sql command
"insert into unitsdata ..........."

However if these values are coming from a form have you considered using controls which are bound to a data set. Pardon the MS Jargon, but have you investigated using the form wizard and basing it on the unitsdata table?. THis will handle all (well most of) the SQL interface issues involved in inserting, adding and deleting records.
HTH
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On