Event Procedures

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.
 
K

Ken Snell \(MVP\)

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

Assuming you always want to hide the control when you move to another
record, use the form's Current event to rehide the control -- make sure that
you move focus to another control first if that control has the focus (in
the code example below, change "NameOfSomeOtherControl" to a real control
name that always can receive the focus):

Private Sub Form_Current()
If Me.ActiveControl.Name = "ContractNoExpirationNotes" Then _
Me.NameOfSomeOtherControl.SetFocus
Me.ContractNoExpirationNotes.Visible = False
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

Add the bisStatusClosed to the query that is being used as the form's
RecordSource, then change your code to this:

Private Sub Status_Change()
If Status = "Closed" Then
If Me.bitStatusClosed.Value = 1 Then
DateClosed = Now()
End If
Else
DateClosed = Null
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


Top