Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create table Automatically

Status
Not open for further replies.

vttech

Technical User
Jan 28, 2006
297
US
I want to create a combo box that contains a list of dates

example

5/20/2006
6/3/2006
6/17/2006
7/1/2006
7/15/2006
7/29/2006
8/12/2006
8/26/2006
9/9/2006


You will notice the dates are in 14 day spans

example:

5/20/2006 + 14 equals 6/3/2006

I know I can create a table and add the dates manually and then base the combo box on that table

The problem is that I don't want to manually create this table.


So I created a Form with

a command Button called cmdCreateTbl

and two text boxes txtStartDate, txtPayPeriods

which populate a table called tblPayPeriods


How can I create a query based on tblPayPeriods that will create the table for me?



Newbie in search of knowledge
 
Since you're just populating a combobox, why not do a loop with a DateAdd from a starting point?
Code:
Private Sub Form_Load()
Dim startDate As Date
startDate = CDate("1/1/2006")
Combo0.AddItem startDate
Do While startDate < CDate("1/1/2010")
    startDate = DateAdd("d", 14, startDate)
    Combo0.AddItem startDate

Loop

End Sub

 
that worked but I have another question regarding the same form

I used the following formula in the Record Source property for a text box

=DateAdd([d],1,[cboDate])

I get #Name? displayed in the text box

What's wrong with this code if both the txtbox and the combo box are on the same form??

Why am I getting this error?




Newbie in search of knowledge
 
Anyway, replace [d] with "d"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top