Recordset

jhartford

Registered User.
Local time
Today, 00:25
Joined
Oct 24, 2008
Messages
12
I have several questions about recordset.

1. create a recordset field's name:

With rstA.Fields
.Append "fName", adChar 'got error.
End With

2. After is is created, I will populate it by following, is it correct?
With rstA
.AddNew
![fName] = rstA![fName]
.Update
End With

Thanks in advance.
 
This does the same thing:

Code:
Dim StrgSQL As String
   
DoCmd.SetWarnings False
StrgSQL = "ALTER TABLE [YourTableName] ADD COLUMN fName TEXT(50);"
DoCmd.RunSQL StrgSQL
StrgSQL = "UPDATE [YourTableName] SET fName='Whatever You Want'"
DoCmd.RunSQL StrgSQL
DoCmd.SetWarnings True


.
 
This does the same thing:

Code:
Dim StrgSQL As String
 
DoCmd.SetWarnings False
StrgSQL = "ALTER TABLE [YourTableName] ADD COLUMN fName TEXT(50);"
DoCmd.RunSQL StrgSQL
StrgSQL = "UPDATE [YourTableName] SET fName='Whatever You Want'"
DoCmd.RunSQL StrgSQL
DoCmd.SetWarnings True


.

CyberLynx,

Thanks a lot for your reply. I need to creata a recordset not a table.
 
My apologies. :o

I assumed by looking at the code you provided that you were trying to use ADO to apply a new Field (column) into a Table then populate that new Field. The code I provided does exactly that. It does not create a Table. ;)

I am still assuming that you are trying to use ADO to accomplish this task since the adChar constant belongs to the ADO Library. Is this indeed the case?

Are you particular with which Library you use to achieve this task? Does it matter if it is done with DAO or is it DAO that you are trying to use?

Once again....my apologies for the confusion.

.
 
Hi

Do you want to elaborate a bit upon what you're trying to accomplish?
Appending the field to the recordset will fail for any of several reasons.
If the recordset is bound to a data source, if it's already been opened, isn't instantiated...
To create recordset fields in this manner you must create the recordset from scratch. Append all fields you require and then open it.
But I'm guessing you want a new column in an existing recordset which is bound to data? Would that be accurate?
If not - then please feel free to elaborate on your requirements - and show your full code.

And yes - you would populate a created recordset in the same manner as you would a data bound one.
(And you're stuck with ADO on this one - DAO doesn't support created recordsets).

Cheers.
 

Users who are viewing this thread

Back
Top Bottom