Populate combo with system date

lmangano

New member
Local time
Today, 07:16
Joined
Nov 29, 2000
Messages
6
Is it possible to have the current day's system date (in the Short Date format) as one of the values in my combo box?

I've played around with =Now() and things like that but it literally displays =Now() as the value and I want it to display 12/13/2000 (for example). I'm thinking I probably have to create a user-defined function that retrieves the system date and use that function name as the property value for RowSourceType?

Any suggestions? Thanks!
 
Since things are a little slow here at work today I tried this little scenario and to my surprise it worked on my first edit.
Wonders will never cease.

Write a function similar to this and use it as the Row Source Type of your combobox. I edited a slightly more complex example that is straight out of the Access97 help file.

Code:
Function DateTest(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant

Select Case code
        Case acLBInitialize         ' Initialize.
            DateTest = True
        Case acLBOpen               ' Open.
            DateTest = Timer        ' Unique ID.
        Case acLBGetRowCount        ' Get rows.
            DateTest = 1
        Case acLBGetColumnCount     ' Get columns.
            DateTest = 1
        Case acLBGetColumnWidth     ' Get column width.
            DateTest = -1           ' Use default width.
        Case acLBGetValue           ' Get the data.
            DateTest = Date
    End Select
End Function

Thanks for the question - I used it as a self-help learning experience.
smile.gif

Shep

By the way, I had typed Date(); Access removed the parentheses automatically. If you use Now(), the parentheses are retained. Alternately, you can use the Format function here to detail this field as you like.

[This message has been edited by Shep (edited 12-13-2000).]
 
Thanks a lot! I was able to figure out a work around between both of you.
 
enter

Date()

in the default value property of the combo box!
 
Hi adamcort,
"Date()" as the default value will populate the entry portion with the current date, indeed, but I think he wanted the date to appear as a choice once the combobox is 'dropped down' or opened.
Either way, it was fun to learn. heh heh
Shep
 

Users who are viewing this thread

Back
Top Bottom