i would like to capture the date when a user first clicks on a command button. i can't use =now() because that is updated all the time. i am only interested in the date when the user FIRST clicks on the button. <br><br>any suggestions?
for the OnClick property try some code as such:<br><b><br>If IsNull(FieldName) Then<br>Me.FieldName.Value = Now()<br>End IF<br></b><br><br>haven't tried this, but it should work. just replace "FieldName" with the name of the field that you want to capture the data in.<br>if that field is Null, then the date will be inserted, otherwise it will keep the current value<br> <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
it doesn't work. here is my code: <br><br>If IsNull(Day1CreateTime) Then<br> Forms![frmDay1].[Day1CreateTime].Value = Now<br>Else<br> End<br>End If<br><br>if i bind the text box (Day1CreateTime) to my table, i get a run time error message 'You can't assign a value to this object'.<br><br>if i create the text box as an unbound text box, i keep getting the current date and time. in other words, the isnull doesn't work. i have also tried:<br><br>If [Day1CreateTime].Value <> "" Then<br> End<br>Else<br> Forms![frmDay1].[Day1CreateTime].Value = Now<br>End If<br><br>but that doesn't work. please help!
so Day1CreateTime isn't a field on the form with the button to set the date? or is it?<br>If it isn't then try to do your code like such:<br><b>If IsNull(Forms![frmDay1].[Day1CreateTime]) Then<br> Forms![frmDay1].[Day1CreateTime].Value = Now<br>End If<br></b><br><br>but, you might also have to do an OpenForm statement to allow you to append to that table.<br><br>try putting this line first:<br><b><br>DoCmd.OpenForm "frmDay1", acNormal, , , acFormAdd, acHidden<br></b><br>and then this line after:<br><b><br>docmd.Close acForm, "frmDay1"<br></b><br> <p>Brian Famous<br><a href=mailto:bfamous@ncdoi.net>bfamous@ncdoi.net</a><br><a href= > </a><br>
This works for me in a bound field. Does your underlying bound field have a date field format? "Now" works for me too but Now actually captures time as well as date and can cause other problems.<br><br>If IsNull(Me!Day1CreateTime) Then<br> Me!Day1CreateTime = Date<br>End If
thank you!!! it works. i had my code in the 'open event' of the second form (frmDay1). but, i moved it to the click event of the command button of the first form and it works.<br>thank you so much. i have spend many hours working and struggling with this. it is nice to know that other people care and are willing to help others. <br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.