Updating Form on Record Change (1 Viewer)

Zippyfrog

Registered User.
Local time
Today, 16:34
Joined
Jun 24, 2003
Messages
103
I have written a database that keeps logs all the track and field results for my school, and I want to make it a little more user friendly. On the form where results are entered, the label for the field where the results are entered says "Final Time" But I want to change the caption based off of whether they have a running event or an event that measures feet/inches. So, for example, if it is a long jump result, I want the label to say long jump.

There is a combo box where the user can choose the event they are adding a result for. And I know the code that I want to add. It is

If me.cboEvent.SelText = "Long Jump" or "Discus" or "Triple Jump" or "Shot Put" or "High Jump" then me.lblFinalTime.Caption = "Best Throw"
End If

I just don't know where to put it. I want this to occur as soon as a user selects an item from the combo box, but I also want the label to change as the user scrolls through the records based off of what was selected in the combo box. I assume to do this, I need to copy and paste the code into two separate events, I just don't know what ones they are. Any help would be greatly appreciated!
 

missinglinq

AWF VIP
Local time
Today, 17:34
Joined
Jun 20, 2003
Messages
6,420
You say you want the Label's Caption to be the same as the Combobox selection but your code example doesn't reflect this! And in point of fact, the code is way off for your needs.

To make the Label Caption echo the Combobox selection:
Code:
Private Sub cboEvent_AfterUpdate()
 If Not IsNull(Me.cboEvent) Then
  EventLabel.Caption = Me.cboEvent.Value
 Else
  EventLabel.Caption = "Event"
 End If
End Sub
To make this persist as you move from record to record
Code:
Private Sub Form_Current()
 If Not IsNull(Me.cboEvent) Then
  EventLabel.Caption = Me.cboEvent.Value
 Else
  EventLabel.Caption = "Event"
 End If
End Sub
Where EventLabel is the Label name. I've used "Event" as the Default Caption, but you can change it to whatever you you'd like it to display until a selection is made from the Combobox.

Linq ;0)>
 

Users who are viewing this thread

Top Bottom