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!

Inserting the current date in a form 2

Status
Not open for further replies.

Lilagt

Technical User
Apr 27, 2000
7
US
I have tried everyway possible to insert the current date (short form) upon the field being double clicked in my form.  Again.. Please Help.. I know this a basic fuction, but try aas I might, I cant get it right.
 
Place this code in the On Dbl Click event of your txtbox.<br><br>Private Sub txtYourDate_DblClick(Cancel As Integer)<br>Me![txtYourDate] = Date<br>End Sub<br><br>Change &quot;txtYourDate&quot; to the name of your textbox.<br><br>HTH<br>RDH <p>Ricky Hicks<br><a href=mailto: rdhicks@mindspring.com> rdhicks@mindspring.com</a><br><a href= > </a><br>
 
Hold down the Ctrl key and press the &quot;;&quot; key.&nbsp;&nbsp;This works on any form without writing code. <p>Jim Conrad<br><a href=mailto:jconrad3@visteon.com>jconrad3@visteon.com</a><br><a href= > </a><br>
 
Thanks Jim that Ctl+ for &quot;copy the same field in the previous record&quot; will be helpful to my users.
 
Create a new entry filed.<br><br>I usually place the following line in the default value field:<br><br>=date()<br><br>Other useful time/date commands are:<br><br>time()<br>now()<br><br>and format$(&quot;dd mmmm dddd&quot;, YourDateField)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format$(&quot;hh:nn&quot;, YourTimeField).<br><br>I have found these command extremely useful in forms and reports.<br><br>I hope these are useful<br><br>Shane Brennan<br>
 
Ok,<br><br>I din't mean to be thick, but I've tried all of these. I suppose I wasnt being clear (I apologize).<br>What I need to do is allow users that open up my form to double clicck on a field and Access will automatically insert the current date. <br><br>I thought the =date() was the best to put in the OnDblClick macro, but it didnt work.<br><br>Thanks a Million for your patience with me!!
 
The OnDblClick is not a <b>macro</b>, it's an <b>event</b>. <br>1. Go into design mode of your form.<br>2. Right click on the control you want to add this functionality to. <br>3. This will bring up the properties box. <br>4. Click on the Event tab, then the &quot;...&quot; button next to On Dbl Click. <br>5. Select Code Builder and click on OK. <br>6. A code window will open. <br>7. Insert Ricky's code between the other two lines of code that appear, like this:<br><br>Private Sub cmdOpenClosetForm_DblClick(Cancel As Integer)<br>Me![txtYourDate] = Date<br>End Sub<br><br>8. substitute the name of your control for what's inside the brackets -&gt; txtYourDate<br>9. if you don't know the name of the control, click on the &quot;Other&quot; tab of your properties form and look under &quot;Name&quot;.<br>10. Good luck :)<br>
 
THANK YOU ALL!<br><br>I finally Got it working!!!<br><br>Is there a code that will cause any field in the form that is double clicked to input the current date (so the code doesn't call out one particular field)? <br><br>
 
Create a procedure in the form:<br><br>Sub InsertDate()<br><br>&nbsp;Screen.ActiveControl=Date<br><br>End Sub<br><br>Then for the Double-click event of all the controls just type Insertdate as the only line in the procedure. Format the textboxes to display the date as desired.<br><br>
 
Thank you for the information. It allowed me a starting point and I easily adapted the code to fit my needs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top