I have an application that allows a user to select a month from a combo box and on the change event will delete a temp table and recreate it with information according to what the user selected. So i.e. the user selects June, temp_Table is dropped and recreated with columns 1-6(1 for Jan, 2 for Feb etc.)
Also in the on change event I have code that includes a counter that counts the columns/fields to know how many months exist. Next a loop runs adding the missing months as fields to the table using the current value of the counter. So if June is selected, the counter should be at 6 and the loop knows to run until it reaches 13 (the first column is not a month). With each iteration in the loop I am using the code below. My question is can I, use a variable to name a field. For example, cnt is my variable. I have scoured the internet all day looking for answer but alas have not been successful in finding one.
Set db = CurrentDb
Set tdf = db.TableDefs("temp_Table")
Do Until cnt = 13
tdf.Fields.Append tdf.CreateField(cnt, dbInteger, 5)
cnt = cnt + 1
Loop