Adding new field to table and populating it

Positive Parrot

New Member
Joined
Jan 16, 2004
Messages
35
I'm very new to Access VB but I have managed to import a CSV file into a table with a DoCmd.TransferText command.

The next thing I'd like to do is create a new integer field in the table (e.g. month) and populate every record with the same value in the new field (e.g. 200503).

I've had a look at commands based on .Fields.Append but haven't got anything to work yet.

Any help would be much appreciated.

Regards,

PP
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Can we see what code you have already?
 
Upvote 0
Norrie,

Thanks for your reply. Here's the code. I've got the extra field now - I'm working on how to populate it now.

Code:
Sub LoadData()

DoCmd.TransferText acImportDelim, "Import_Spec", "Temp", "P:\Tgb01\Costs by User Feb-05.csv", True

strSQL = "ALTER TABLE Temp ADD COLUMN Month Integer"
DoCmd.RunSQL strSQL

End Sub

Regards,

PP
 
Upvote 0
Try using an update query in the same way you used the ALTER TABLE.
 
Upvote 0
Norie,

Thanks - I got there with SQL commands UPDATE and SET.

I can see now that Access developers use a mix of SQL and VBA.

Regards,

PP
 
Upvote 0

Forum statistics

Threads
1,221,902
Messages
6,162,726
Members
451,782
Latest member
LizN

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top