Combo box

M

Mike

Can someone tell me how to populate a combo box with Formated Date of yyyy
say from 1999 to current year
 
M

Mr B

Mike,

Place the following code in the OnOpen event of your form:

Dim strRowSource As String
Dim varCntr As Byte
Dim cntr

varCntr = Val(Year(Date)) - 1999
strRowSource = "1999"
For cntr = 1 To varCntr
strRowSource = strRowSource & "; " & Str(1999 + cntr)
Next cntr
With Me.cboYear
.RowSource = strRowSource
.Requery
End With

Change the Me.cboYear to the name of your combo box.
 
M

Mike

Thank You Mr.B

Mr B said:
Mike,

Place the following code in the OnOpen event of your form:

Dim strRowSource As String
Dim varCntr As Byte
Dim cntr

varCntr = Val(Year(Date)) - 1999
strRowSource = "1999"
For cntr = 1 To varCntr
strRowSource = strRowSource & "; " & Str(1999 + cntr)
Next cntr
With Me.cboYear
.RowSource = strRowSource
.Requery
End With

Change the Me.cboYear to the name of your combo box.
--
HTH

Mr B
askdoctoraccess dot com
 

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