Making table and fields

S

Sam

I want create table which name is current month +6. So in this case it would
be "December". This table should contain fields as much as days in that month
(31). The field names should be 1...31. I know all separate prosedures needed
in this, but I have troubles of making them work together. I'm using the code
below to create the table with one field. Can somebody help me a bit? Or does
someone has easier way of doing this?

Set NewTable = db.CreateTableDef("NewTable") 'create the table
With NewTable
..Fields.Append .CreateField("field", dbText, 20)
End With
 
J

John Spencer (MVP)

My question to this is why? Tables and fields should not normally contain data
- month names are data, day numbers are data.

If you really feel the need to do this then here are a few clues.

To get the month name
Format(DateSerial(Year(Date()),Month(Date())+6,1),"mmmm")

To get the number of days in the month.
Day(DateSerial(DateSerial(Year(Date()),Month(Date())+7,0))

Use a loop to append the fields 1 to n

BUT, can you explain why you think you need to do this. You would almost always
be better off having a table with the structure

ActionDate
StoredValue

You can then add records to that table and use queries to extract all the data
that is relevant for any particular date range.
 
S

Sam

Thank you for advice. I want to accomplish following. I want to have 12
tables, one for each month in year. I want to use these tables to book
certain days through a form. This is why I figured that it would be easiest
to have day numbers as a names of the fields.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top