hiding button

A

Alan

Hi folks,

I thought what I was trying to do was simple but it doesn't seem to be
working. I have a form where there's a date field (saveDate) of when the data
was saved which is filled in when the save button is clicked (btnSavePkg). I
only want this button used once when the data is first entered to show when
the data was initially entered. After the saveDate field is populated with a
date, I want that save button to disappear therefore on the Afterupdate event
of the date field (saveDate) I wrote the following code:


Private Sub saveDate_AfterUpdate()

If Me.saveDate = " " Then
Me.btnSavePkg.Visible = True
Else
Me.btnSavePkg.Visible = False
End If

End Sub

This doesn't seem to be working. I can click the "btnSavePkg" button and it
will write the current date into the "saveDate" field but the button doesn't
disappear afterwords.

Is my code wrong or is my logic wrong?

Thanks in advance.

Al
 
D

Douglas J. Steele

Setting a value programmatically doesn't trigger the AfterUpdate event.

Call that routine explicitly in your Click event:

Private Sub btnSavePkg_Click()

Me.saveDate.Value = Now()
Me.saveDate.SetFocus
Call saveDate_AfterUpdate

End Sub

(You need to move the focus from btnSavePkg since you cannot make a control
that has focus invisible)
 
A

Alan

That worked great!

Thanks Douglas.

Al

Douglas J. Steele said:
Setting a value programmatically doesn't trigger the AfterUpdate event.

Call that routine explicitly in your Click event:

Private Sub btnSavePkg_Click()

Me.saveDate.Value = Now()
Me.saveDate.SetFocus
Call saveDate_AfterUpdate

End Sub

(You need to move the focus from btnSavePkg since you cannot make a control
that has focus invisible)
 

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