Add to my AfterupDate

B

Bob

--

How do I add this to my script:
subSetValues

If tbStableReturnDate.value = "" Or IsNull(tbStableReturnDate.value) Then
tbStableReturnDate.value = Format(Now, "dd-mmm-yy")
End If
End Sub



Thanks for any Help

.........Bob Vance
 
A

Arvin Meyer [MVP]

I'd use it like this:

If Len(Me.tbStableReturnDate & vbNullString) = 0 Then
Me.tbStableReturnDate = Format(Date, "dd-mmm-yy")
End If

vbNullString will return 0 if tbStableReturnDate is either Null or Empty.
Only use Now if you need the time as well as the date. The value property of
a control is the default.
 
B

Bob

Thanks Arvin I will give it a go.....Bob

Arvin Meyer said:
I'd use it like this:

If Len(Me.tbStableReturnDate & vbNullString) = 0 Then
Me.tbStableReturnDate = Format(Date, "dd-mmm-yy")
End If

vbNullString will return 0 if tbStableReturnDate is either Null or Empty.
Only use Now if you need the time as well as the date. The value property
of a control is the default.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
B

Bob

Arvin Its not holding the information when I quit and re open my db, funny
enough it holds the date if I manually enter it in but the Description box
with the code is not holding any information....Thanks bob
 
R

Richard Williams

Bob said:
Arvin Its not holding the information when I quit and re open my db, funny
enough it holds the date if I manually enter it in but the Description box
with the code is not holding any information....Thanks bob
This is just a guess but the title of your post implies that you are calling
the code in the After Update event of the form. I think you need to call it
in the Before Update event.
 
B

Bob

Richard Williams said:
This is just a guess but the title of your post implies that you are
calling the code in the After Update event of the form. I think you need
to call it in the Before Update event.
thanks Richard that worked, but if there is already a date in date box it
will not over ride the earlier date.....Thanks bob
 
A

Arvin Meyer [MVP]

Your code only adds the date if there isn't a date already in
tbStableReturnDate. If you want to add the date regardless of anything in
the textbox, forget the If ... Then statement and just use:

Private Sub Form_BeforeUpdate (Cancel As Integer)
Me.tbStableReturnDate = Format(Date, "dd-mmm-yy")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AfterUpdate Question! 9
Change Form to No Save 5
Command Button Query 3
Date format query 7
No Message box to show! 1
Date Problem 2
New Field to my Query 6
Add to AfterUpdate 3

Top