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

update field without code?

Status
Not open for further replies.

wxkeep

Programmer
Jul 5, 2005
57
US
I have a button (actually a label with an onclick) that when you click it - it sets the value of a nearby textfield to today's date. I'm using VBA code (code builder) to achieve this. I have more than one label though that to assign this too - and wondered if there were an easier way - perhaps put all the code in just the onclick event without putting it in the VBA side? I tried to just put sometext = Date() in the OnClick event - but it errored on me and I don't know why.
 
In the code for the form it is on you create a function call it setdate

Private Function setDate()
txtName = Date()
End Function


THEN in each On_Click even you put

=setDate()


And all your problems are solved.


( If you create a Switchboard - using the built in switchboard wizard, it uses this functionality in as slightly more complex way - so you can see how this feature can be used more flexibly than the simple example you are using here. )


'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
That really got me going in the right direction - thanks! The only difference is that my form had multiple textboxes each with their own label to act as a button for entering today's date.

So I changed the function

private function setdate(x as Textbox)
x=date()
End function

And then in the onclick
=setdate(NameofTextbox)

Thanks again for the help - that may make a LOT of things easier!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top