guardian262
New member
- Local time
- Today, 16:20
- Joined
- Dec 26, 2008
- Messages
- 5
Good morning everyone.
I am creating a database for issuing and tracking Government Driver's Licenses. I have 7 Combo boxes to select different vehicle types. If a certain vehicle is selected in one of the 7 combo boxes I want to check a box associated with that vehicle type. Here is the code and the error I get.
Private Sub Form_AfterUpdate()
If Me.Vehicle1 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle2 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle3 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle4 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle5 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle6 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle7 = "LIGHT VEH THRU" Then
Me.LightVeh = True
Else
Me.LightVeh = False
End If
If Me.Vehicle1 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle2 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle3 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle4 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle5 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle6 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle7 = "PASS VEH THRU" Then
Me.PassVeh = True
Else
Me.PassVeh = False
End If
If Me.Vehicle1 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle2 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle3 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle4 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle5 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle6 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle7 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
Else
Me.Trk4X4 = False
End If
If Me.Vehicle1 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle2 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle3 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle4 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle5 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle6 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle7 = "TRK TLR THRU" Then
Me.TrkTlr = True
Else
Me.TrkTlr = False
End If
If Me.Vehicle1 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle2 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle3 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle4 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle5 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle6 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle7 = "FORKLIFT THRU" Then
Me.Forklift = True
Else
Me.Forklift = False
End If
If Me.Vehicle1 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle2 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle3 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle4 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle5 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle6 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle7 = "UTILITY ATV THRU" Then
Me.ATV = True
Else
Me.ATV = False
End If
If Me.Vehicle1 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle2 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle3 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle4 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle5 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle6 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle7 = "HMMWV M998 THRU" Then
Me.HMMWV = True
Else
Me.HMMWV = False
End If
End Sub
The good news is that after I update the Check Boxes are functioning correctly. The bad news is that the pencil in the upper left corner does not change to the triangle and it will not let me advance to the next record. When I close the form, a box pops up that says:
"You cant save this record at this time"
"Microsoft Office Access may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost. Do you want to close the database object anyway?"
When I close and come back in, the changes have been made and I can advance to the next record as long as I don't make any changes to the data in the form. What am I missing? Thanks in advance for any help.
Shawn
I am creating a database for issuing and tracking Government Driver's Licenses. I have 7 Combo boxes to select different vehicle types. If a certain vehicle is selected in one of the 7 combo boxes I want to check a box associated with that vehicle type. Here is the code and the error I get.
Private Sub Form_AfterUpdate()
If Me.Vehicle1 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle2 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle3 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle4 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle5 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle6 = "LIGHT VEH THRU" Then
Me.LightVeh = True
ElseIf Me.Vehicle7 = "LIGHT VEH THRU" Then
Me.LightVeh = True
Else
Me.LightVeh = False
End If
If Me.Vehicle1 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle2 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle3 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle4 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle5 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle6 = "PASS VEH THRU" Then
Me.PassVeh = True
ElseIf Me.Vehicle7 = "PASS VEH THRU" Then
Me.PassVeh = True
Else
Me.PassVeh = False
End If
If Me.Vehicle1 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle2 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle3 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle4 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle5 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle6 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
ElseIf Me.Vehicle7 = "TRK 4X4 THRU" Then
Me.Trk4X4 = True
Else
Me.Trk4X4 = False
End If
If Me.Vehicle1 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle2 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle3 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle4 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle5 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle6 = "TRK TLR THRU" Then
Me.TrkTlr = True
ElseIf Me.Vehicle7 = "TRK TLR THRU" Then
Me.TrkTlr = True
Else
Me.TrkTlr = False
End If
If Me.Vehicle1 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle2 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle3 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle4 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle5 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle6 = "FORKLIFT THRU" Then
Me.Forklift = True
ElseIf Me.Vehicle7 = "FORKLIFT THRU" Then
Me.Forklift = True
Else
Me.Forklift = False
End If
If Me.Vehicle1 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle2 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle3 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle4 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle5 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle6 = "UTILITY ATV THRU" Then
Me.ATV = True
ElseIf Me.Vehicle7 = "UTILITY ATV THRU" Then
Me.ATV = True
Else
Me.ATV = False
End If
If Me.Vehicle1 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle2 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle3 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle4 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle5 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle6 = "HMMWV M998 THRU" Then
Me.HMMWV = True
ElseIf Me.Vehicle7 = "HMMWV M998 THRU" Then
Me.HMMWV = True
Else
Me.HMMWV = False
End If
End Sub
The good news is that after I update the Check Boxes are functioning correctly. The bad news is that the pencil in the upper left corner does not change to the triangle and it will not let me advance to the next record. When I close the form, a box pops up that says:
"You cant save this record at this time"
"Microsoft Office Access may have encountered an error while trying to save a record. If you close this object now, the data changes you made will be lost. Do you want to close the database object anyway?"
When I close and come back in, the changes have been made and I can advance to the next record as long as I don't make any changes to the data in the form. What am I missing? Thanks in advance for any help.
Shawn