Click to See Complete Forum and Search --> : Populate Recordset


tjosten2921
March 20th, 2001, 10:43 AM
I need a way to be able to populate a recordset. I have an Access database created and need to enter a list of times and dates for a year. I was wondering if their is a way to automatically populate these so I don't have to enter them all in. Thank You. Ted

Johnny101
March 20th, 2001, 12:59 PM
where are you getting this information from? a text file? - your head? - someone else's head? - another database? each of those options have a different way of getting the info into the database.

john

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org

Johnny101
March 21st, 2001, 11:03 AM
You could write a script to do this. maybe, something like this:

'psuedo code

'open your connection, named cn

dim sql as string
dim i as integer, j as integer

'since you are needing an entry for every half-hour for a work day - go through a loop
'and add rows...

for i = 8 to 17
sql = "INSERT INTO YourTable (TimePeriod) VALUES "
sql = sql & "('" & i & ":00')"

cn.Execute sql, adExecuteNoRecords

sql = "INSERT INTO YourTable (TimePeriod) VALUES "
sql = sql & "('" & i & ":30')"

cn.Execute sql, adExecuteNoRecords

next i




it adds an entry for 5:30 PM though - you could easily put a check in for " if i = 17 then dont do the :30 insert".

If you need to do this for each day in the year, you'll have to put this inside another loop that go through the days. the trick there will be determining the weekends versus the work-week.

hope this helps,

john


John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org