|
-
Feb 20th, 2003, 05:58 PM
#1
.Update Method
When updating values in a Row of a Recodset, which is the 'correct' option:
VB Code:
rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
With rs
.Update "Project_Title", cboProject_Title.Value
.Update "Date_Entered", txtDate_Entered.Value
.Update "Title", txtTitle.Value
End With
rs.Update
rs.Close
Or
VB Code:
rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
With rs
.Fields("Project_Title") = cboProject_Title.Value
.Fields("Date_Entered") = txtDate_Entered.Value
.Fields("Title") = txtTitle.Value
End With
rs.Update
rs.Close
Cheers,
Bruce.
-
Feb 21st, 2003, 01:27 AM
#2
Hyperactive Member
Re: .Update Method
Originally posted by Bruce Fox
When updating values in a Row of a Recodset, which is the 'correct' option:
VB Code:
rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
With rs
.Update "Project_Title", cboProject_Title.Value
.Update "Date_Entered", txtDate_Entered.Value
.Update "Title", txtTitle.Value
End With
rs.Update
rs.Close
Or
VB Code:
rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
With rs
.Fields("Project_Title") = cboProject_Title.Value
.Fields("Date_Entered") = txtDate_Entered.Value
.Fields("Title") = txtTitle.Value
End With
rs.Update
rs.Close
Cheers,
Bruce.
I would also like to know.
I use :
VB Code:
With rs
!Project_Title = cboProject_Title.Value
!Date_Entered = txtDate_Entered.Value
!Title = txtTitle.Value
End With
Anything wrong with that?
-
Feb 21st, 2003, 03:43 AM
#3
Lively Member
Bruce I always use your second method as it means only one update which will presumably be faster than the 1st method.
JFK
-
Feb 21st, 2003, 03:52 AM
#4
Frenzied Member
Originally posted by JFK
Bruce I always use your second method as it means only one update which will presumably be faster than the 1st method.
JFK
Same here, it also is better to have an update that works all the way than half.
When there is a value which can't be inserted into a certain field then the update won't go through for the whole record.
If instead there were already two or more fields updated you got a problem.
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
-
Feb 21st, 2003, 06:58 AM
#5
Thanks Guys,
BTW I was using the second method. I just had to get a warm n fuzzy tho 
I guess my question stemed from the syntax for .Update, like:
rs.Update(Fields, Value) and from that thought the first
method may (should) be the way to go.
Like, you would generaly have say:
VB Code:
rs.Open bla bla bla
[b]rs.AddNew[/b]
'
' manipulae the RecordSet
'
rs.Close
where the rs Command directly followed the rs.Open statement.
Anyhoo,
Cheers.
Bruce.
Last edited by Bruce Fox; Feb 21st, 2003 at 07:03 AM.
-
Feb 21st, 2003, 07:06 AM
#6
Originally posted by swatty
When there is a value which can't be inserted into a certain field then the update won't go through for the whole record.
If instead there were already two or more fields updated you got a problem.
Good point swatty!
Bruce.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|