ado recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello I am trying to create and populate a recordset using ADO. Here is my
code:

Dim dbcurr As ADODB.Connection
Dim rstCurr As ADODB.Recordset

Set dbcurr = CurrentProject.Connection
Set rstCurr = New ADODB.Recordset


With rstCurr
..Fields.Append "From", adVariant
..Fields.Append "Date Sent", adDate
..Fields.Append "Subject", adVariant
..Fields.Append "Attachment_number", adInteger
..Fields.Append "Attachment_name", adVariant
End With

rstCurr.Open
rstCurr.AddNew
rstCurr.Fields("From") = "from"
rstCurr.Fields("Date Sent") = "sent"
'rstCurr.Fields("Subject") = "subject"
rstCurr.Update


However, I get the following error:

Multi-step operation generated errors. Check each status value.
 
Tom,

I have never created a recordset in memory as you have done below, perhaps
you want to create a table first and then create an updatedable recordset
based on the tables and update (as you hav done in the second part of the
code below. What is it that you are trying to do?

Dan
 
.Fields.Append "Date Sent", adDate
rstCurr.Fields("Date Sent") = "sent"

The text "sent" is not a valid value for a Date/Time field.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Tim Ferguson said:
The text "sent" is not a valid value for a Date/Time field.

Is the field name "Date Sent" legal, or should it be "[Date Sent]"?

AFAIK when you're referring to field names like that (as an index for a
collection), you don't need the square brackets.
 
As Doug says elsewhere in this thread, I believe it is OK in this context.
But I prefer to deal with one bug at a time! :-) If the original poster
posts back to say he fixed the text-to-date/time bug and is still getting
errors, then I'll go hunting for other bugs, but not before! :-)

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.


Tim Ferguson said:
The text "sent" is not a valid value for a Date/Time field.

Is the field name "Date Sent" legal, or should it be "[Date Sent]"?

Tim F
 
Back
Top