Command Button Query

B

Bob

--

I have a command button that enters Todays date, is it possible to add to
the code that If I click it again and their is a date in the text box it
will delete it then if I click it again and it is Blank it will enter
today's date
thanks for any help...............Bob

Private Sub Command440_Click()
tbBox9Date.value = Format(Now(), "dd-mmm-yy")

End Sub





..........Jenny Vance
 
G

Guest

Bob,

Try the following:

Private Sub Command440_Click()
If isnull(me.tbBox9Date) then
Me.tbBox9Date.value = Format(Date(), "dd-mmm-yy")
Else
Me.tbBox9Date=Null
End if
End Sub

You should also try to give appropriate names to your controls (trust me it
will get ugly if you don't) and don't forget to add some error handling.

Daniel
 
D

Douglas J. Steele

Private Sub Command440_Click()
If Len(Me.tbBox9Date & vbNullString) > 0 Then
Me.tbBox9Date = Null
Else
Me.tbBox9Date = Format(Now(), "dd-mmm-yy")
End If
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

Date Problem 2
Alteration to BeforeUpdate 1
Date format query 7
Add to my AfterupDate 7
AfterUpdate Question! 9
Command Button colour? 4
Form filter & macro 4
New Field to my Query 6

Top