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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Date() as default value for bound textbox?

Status
Not open for further replies.

eavan

Technical User
Aug 6, 2003
51
GB
Hey guys,

thanks for all your help the last few days.I am wondering would you know a way of setting the value of a form text box can default to be the current date when they enter a form. I have tried to use onOpen (for the Form) set value be Date() but tells me this is not allowed to be set. Can anyone tell me how this could be worked around.Thanks a mill
 
Within the property window, the Data tab, there is a property for DefaultValue. All you need do is enter =Date().
 
sorry i should have mentioned that i did that already but it is not working for a bound textbox.It will work for the unbound.I have tried a few workarounds like onEnter or onOpen etc but not happening for me.Cheers
 
How are ya eavan . . .

In the [blue]Default Value[/blue] property of the textbox enter [purple]Date()[/purple]

Calvin.gif
See Ya! . . . . . .
 
Eavan,

The default value will only work on new records, not existing records. An unbound textbox would work like a new record, as there is no data (including blank) already in the field. So, now the question is: Are you wanting to "default" the date in all records looked at by users, or just the new records?

If all users, then I would suggest putting the "=Now()" into the OnCurrent event, or if you want this done only if the user changes something, then put it into the AfterUpdate event.

Vic
 
Eavan,

Is this supposed to be populating the date against newly created records? If so I'd recommend setting the default value of the field in the table, rather than the textbox on the form. Doing so will ensure that however the record is created the field will always be populated with the value that you want.

Ed Metcalfe.

Please do not feed the trolls.....
 
thanks a mill guys.I have decided to use a setvalue macro in the afterupdate function of a textbox. Works a treat and actually makes better sense to have the user working this way. Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top