Check box After_Update error will not advance to next record

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
 
Can you post a picture of your input form?
 
Here are 2 pictures in normal and edit mode. Something I noticed that I didn't before, it looks like the form doubled up in normal view for some reason.

DLDatabase.jpg


DLDatabase1.jpg
 
Looks like you have some serious normalization problems going on here. I think anything that is suggested will only be a band-aid fix for a much greater problem that should be fixed first.
 
Kind of what I expected and I'm with Bob on this one. If you intend to go any further than a simple report or two and want to be able to do simple things like adding or deleting trucks, instructors, etc. then I highly recommend do a bit of reading up on normalization...
 
So basically, the short answer is to fix the normalization and the code that I had would work?

For normalization, are you takling about how my fields are named or spliting up the tables and using keys to link the information? Obviously I haven't had any formal training in Access. This has really been trial by fire for me. Other than reading a book on the basics (which to my dismay did not even touch on normalization) and reading a few things on the web about normalization I have been going by trial and error.
 
So basically, the short answer is to fix the normalization and the code that I had would work?

No. You could possibly get the code to work but there are larger problems with how you have the data set up...
 

Users who are viewing this thread

Back
Top Bottom