Forms - Event Procedure Help

M

mralmackay

Hoping that someone can help with the following few queries...

1) I have the following procedure, which is used to unhide a field if
a tickbox is ticked. This works fine on the existing 'record'.
However when I navigate to other records it still remembers the tick
box option of the previous record? Any ideas?

Private Sub ContractNoExpiration_AfterUpdate()
If ContractNoExpiration = True Then
ContractNoExpirationNotes.Visible = True
Else
ContractNoExpirationNotes.Visible = False
End If
End Sub

2) I have the following procedure for when the Status is Changed to
Closed. Basically this will then set the Date Closed field to be
current date/time. However, I now need to be a bit more flexible with
this so what I'd like to do is add on an extra field within the status
table which I've named bitStatusClosed. This is either set to 0
(open) or 1 (closed). Would it be possible to amend this query to
actually look @ the attribute of the status and if it's = 1 then set
the closed date?

Private Sub Status_Change()
If Status = "Closed" Then
DateClosed = Now()
Else
DateClosed = Null
End If
End Sub

Thanks in advance for any help. Really appreciated. Al.
 
A

Allen Browne

Re #1, use the Current event of the form as well as the AfterUpdate event of
the control:
Private Sub Form_Current()
Call ContractNoExpiration_AfterUpdate
End Sub

(It will be important to add error handling to
ContractNoExpiration_AfterUpdate, in case the Notes field has focus when you
try to hide it.)

Re #2, use the AfterUpdate event of the control. (If you must use Change for
some reason, examine the Text property of the control, not its Value.)
 

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


Top