What event occurs After form record is loaded

D

Duck

I have a form with a control called [ContactType] that I want to be
either visible or invisible dependant on the value of a checkbox
called [Contacts]. The problems is that the coded works fine when
attached to the click event of the [Contacts] checkbox. However I
can't get the [ContactType] to be visible when the form first loads
with a clients data. It doesn't seem to matter which form event for
the form I tie the code to the value of the checkbox is always null.
But if I check the value of the checkbox after the form is loaded and
displaying the record it is either -1 or 0 (of course depending on
whether or not it is checked). The code is simple:

'Open with ContactsType inactive if the patient does not wear them
chkContacts.Requery

Debug.Print "Value is " & Forms!frmCustomerInput!
cmbContactType.Value


If IsNull(Forms!frmCustomerInput!chkContacts.Value) Then
Debug.Print "It is nullg"
End If

If chkContacts.Value = 0 Then
Debug.Print "No Contacts " & chkContacts.Value
cmbContactType.Enabled = False
cmbContactType.Visible = False
LblContactType.Visible = False
End If

If chkContacts.Value = -1 Then
Debug.Print "Contacts True " & chkContacts.Value
cmbContactType.Enabled = True
cmbContactType.Visible = True
LblContactType.Visible = True
End If
 
A

Arvin Meyer [MVP]

The Order of events for forms and subforms is one topic covered well in
Access help files. Just click on F1 and type:

Order of events

and you should get a number of choices. Here is something from Access 97
which had the best help files, but is not up to date. It should cover your
situation though:

Order of events for forms and subforms

Events occur for forms when you open or close a form, move between forms, or
work with data on a form.
Opening and closing a form
When you open a form, the following sequence of events occurs for the form:

Open >>> Load >>> Resize >>> Activate >>> Current

If there are no active controls on the form, the GotFocus event also occurs
for the form after the Activate event but before the Current event.
When you close a form, the following sequence of events occurs for the form:

Unload >>> Deactivate >>> Close

If there are no active controls on the form, the LostFocus event also occurs
for the form after the Unload event but before the Deactivate event.
Moving between forms
When you switch between two open forms, the Deactivate event occurs for the
first form, and the Activate event occurs for the second form:

Deactivate (form1) >>> Activate (form2)

The Deactivate event for a form also occurs when you switch from the form to
another window in Microsoft Access. However, the Deactivate event doesn't
occur when you switch to a dialog box, to a form whose PopUp property is set
to Yes, or to a window in another application.

Note An Open event doesn't occur if you move to a form that is already
open, even if you've moved to the form by carrying out an OpenForm action.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Duck said:
I have a form with a control called [ContactType] that I want to be
either visible or invisible dependant on the value of a checkbox
called [Contacts]. The problems is that the coded works fine when
attached to the click event of the [Contacts] checkbox. However I
can't get the [ContactType] to be visible when the form first loads
with a clients data. It doesn't seem to matter which form event for
the form I tie the code to the value of the checkbox is always null.
But if I check the value of the checkbox after the form is loaded and
displaying the record it is either -1 or 0 (of course depending on
whether or not it is checked). The code is simple:

'Open with ContactsType inactive if the patient does not wear them
chkContacts.Requery

Debug.Print "Value is " & Forms!frmCustomerInput!
cmbContactType.Value


If IsNull(Forms!frmCustomerInput!chkContacts.Value) Then
Debug.Print "It is nullg"
End If

If chkContacts.Value = 0 Then
Debug.Print "No Contacts " & chkContacts.Value
cmbContactType.Enabled = False
cmbContactType.Visible = False
LblContactType.Visible = False
End If

If chkContacts.Value = -1 Then
Debug.Print "Contacts True " & chkContacts.Value
cmbContactType.Enabled = True
cmbContactType.Visible = True
LblContactType.Visible = True
End If
 

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