Checking if Text Box is empty

T

tboggs25

I have a text box that is used for notes in a form. It is set to text with
255 characters in the table. One of the users requested a Date Stamper (a
button to automatically put today's date in the text box).

My problem is that if there is something already in the text box, the code
that I wrote will erase the current notes and put the date in the text box.
Now I am trying to check the text box for empty value. If there is
information in that text box, I want the Date Stamp to just add at the end of
the last entered character.

The text box is used to make small notes, such as, I called this person, I
sent this person email, many many different variables (thats why the user
needs a text box so they are free to type what they did). So you can imagine
why they want a date next to each action.

Here is the code that I have currently - the error is that I am improperly
using Null

Private Sub DateStamper_Click()

Dim tempStrg As String
Dim outStrg As String
Dim dateStamp As String
Dim currentNotes As String

'getting the date
tempStrg = Now()
'formatting the date for output
outStrg = Left(tempStrg, 4)

'adding additional format to the FINAL date output
dateStamp = outStrg & " - "

If IsNull(Me.Notes) Then
'Text box is empty so adding the Date Stamp
Me.Notes = dateStamp
Else
'getting current notes
currentNotes = Me.Notes
'adding Date Stamp to the end of the current notes
Me.Notes = currentNotes & " " & dateStamp
End If

End Sub


Any help would be greatly appreciated!!!
 
L

Leslie Isaacs

Hello

I'm not one of the experts that offers solutions in these newsgroups, but
try this:

Set the AfterUpdate event for the textbox to something like
[myTextBox].Value = [myTextBox].Value & " (" & Now() & ")"

Les
 
M

Michael Gramelspacher

I have a text box that is used for notes in a form. It is set to text with
255 characters in the table. One of the users requested a Date Stamper (a
button to automatically put today's date in the text box).

My problem is that if there is something already in the text box, the code
that I wrote will erase the current notes and put the date in the text box.
Now I am trying to check the text box for empty value. If there is
information in that text box, I want the Date Stamp to just add at the end of
the last entered character.

The text box is used to make small notes, such as, I called this person, I
sent this person email, many many different variables (thats why the user
needs a text box so they are free to type what they did). So you can imagine
why they want a date next to each action.

Here is the code that I have currently - the error is that I am improperly
using Null

Private Sub DateStamper_Click()

Dim tempStrg As String
Dim outStrg As String
Dim dateStamp As String
Dim currentNotes As String

'getting the date
tempStrg = Now()
'formatting the date for output
outStrg = Left(tempStrg, 4)

'adding additional format to the FINAL date output
dateStamp = outStrg & " - "

If IsNull(Me.Notes) Then
'Text box is empty so adding the Date Stamp
Me.Notes = dateStamp
Else
'getting current notes
currentNotes = Me.Notes
'adding Date Stamp to the end of the current notes
Me.Notes = currentNotes & " " & dateStamp
End If

End Sub


Any help would be greatly appreciated!!!
try this:

Me.Notes = (Me.Notes + " - ") & Left(Now(), 4)
 

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

Top