Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Text To Change 1

Status
Not open for further replies.

Quintios

Technical User
Mar 7, 2002
482
0
0
US
I tried this a couple different ways but it's just not working. I want a label or text box to show a different string depending on whether or not a field in the current record contains anything. The label pertains to a subform whose record source is a subset table to the main table. Clear as mud?

I tried putting this code in the Form_Activate event of the subform, but it didn't work:

Code:
    If IsNull(Me.SimTemplateID) Then
        Me.TemplateExists.Caption = "Template is Chosen"
    Else
        Me.TemplateExists.Caption = "Template is Missing"
    End If

So then I stuffed it into the click event of a button and it worked fine.

How do I get the text or caption to change whenever the form is pulled up or the user navigates to a new record? Should the code go in the Main form or the SubForm or into a module somewhere?

Thanks in advance,
Onwards,

Q-
 
Q,

Try putting your code in the On Current event of the form.

Mike
 
YEA!!! Thank you!

If you don't mind, could you explain the difference between 'Current' and 'Activate'? I'll go read the help files too...
Onwards,

Q-
 
Q,

The primary difference is the category of events that the two fall into and the cause of the events. The Activate event is a Focus Event. These events occur when an object gets or loses the focus, or a form or report becomes active or inactive. The Activate event doesn't occur for subforms only for the main form when it opens or when moving between two forms.

The Current event is a Data Event and occurs when displaying records in a form or moving the focus from one record to another in a form. Therefore, when you activated your form the caption reflected its value based on the record displayed and did not change because the event occured one time. Once the code is moved to the Current event it is triggered each time you move to a different record and the caption changes accordingly.

In Access help look under order of events for forms and subforms.

Have fun.

Mike



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top