AfterUpdate

  • Thread starter Thread starter richard
  • Start date Start date
R

richard

I have never coded in access, nor used it but have basic
programming knowledge. How do you you use the afterUpdate
function for fields? I would like to have the user select
from a listbox on an access form and display other fields
depending on the selection? What specifically do I do to
enter the code and how do I reference the fields? This is
my basic algorithm:

afterUpdate (not sure how this is implemented)

If field1 = selection1 then (need to know how to reference)
{
field2 = visible (unsure of how to reference)
field3 = visible
}
ElseIf field1 = selection2 then
{
field4 = visible
field5 = visible
}
 
Richard,

AfterUpdate like all the others is known as an event. To run code when an
event occurs, go to the properties of the text box (or other form object)
you are interested in. Under the EVENT tab find the row called AfterUpdate.
Click on the box to the right of the word. You will then see elipses (...)
to the right of this box. Click on it. This will bring up a pop-up asking
what you want to do. Select code builder. This will bring up the VBA code
window and place the cursor at the location to start entering your code. If
you previous had code, clicking on the elipses will bypass the pop-up and
take you directly to the VBA window.

The code you want to enter would be as follows:

If txtBox1 = "Blue" then
txtBox2.Visible = True
txtBox3.Visible = True
ElseIf txtBox1 = "Red" then
txtBox4.Visible = True
txtBox5.Visible = True
End If

When coding a form, you need to reference the name of the form and not the
name of the field that the data is from. The name of the object is located
under the OTHER tab of the properties.

Kelvin
 
Back
Top