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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running code for each form...

Status
Not open for further replies.

grantoj

Instructor
Nov 26, 2007
1
US
Hello all,

I'm working on setting up a continuous form to display a summary of different insurance claims for the past week. I want to have a text box that would change based on whether certain checkboxes where checked or certain drop-down menu items picked.

I got it to work for the first record in my form, but for some reason the same value is then assigned to the other records in the form. So I am guessing that Access is running my code once and then assigning the same word to each label. So how do I make sure that it runs the code for each record and changes the text box on each record accordingly? I tried changing the code around without the variable EventID and such, but I have had no luck. Any ideas?

Code Pasted Below:



Public Sub Form_AfterUpdate()
Dim EventID As String
If [txtWCType] = "Nurse Case Mgt." Then
EventID = "Comp."
ElseIf [txtWCType] = "Med Only" Then
EventID = "Med"
ElseIf [txtWCType] = "Notice Only" Then
EventID = "Notice"
ElseIf [txtGLType] = "Property Damage" Then
EventID = "PD"
ElseIf [txtGLType] = "Bodily Injury" Then
EventID = "BI"
ElseIf [chkPETheft].Value = True Then
EventID = "Theft"
ElseIf [chkPEDamage].Value = True Then
EventID = "Damage"
ElseIf [chkAUCollision].Value = True Then
If [chkAULiability].Value = True Then
EventID = "Col./Liab."
Else
EventID = "Col."
End If
ElseIf [chkAULiability].Value = True Then
EventID = "Liab."
ElseIf [chkAUComprehensive].Value = True Then
EventID = "Comp."
End If
[lblClaim].Caption = EventID
End Sub
 
You need to run the code in the Current Event of the form. You would be better using Select Case and putting the code in a procedure, which can be called from suitable events.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top