J
Jason Lopez
I am trying to put some VB code in as a form of validation on an Access
form. What I am looking for is essentially the ability to check 5 different
controls for data contained within. The controls are for dates that are
tied to a table that records the training completion dates. In an effort to
avoid out-of-sequence training or edits to the data after the initial entry,
I am wanting to put in this code. It essentially enables the field for
putting in data but disables subsequent fields to maintain the training
sequence.
This is what I have so far (and it is *long* down below). At this point, I
cannot seem to get it to work right. It immediately locks down the form
when there are dates in the fields. The only other thing that I can think
of is to have this same VB code for the BeforeUpdate, On_Click and
AfterUpdate events.
Jason Lopez
Private Sub Form_Load()
If Me!BFT = 0 Then
Me!BFT.Enabled = True
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = False
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = True
Else
If Me!BFT <> 0 & Me!UPT1 = 0 Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = True
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = False
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = True
Else
If Me!BFT & Me!UPT1 <> 0 & Me!UPT2 = 0 Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = True
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = False
Me!IFF.Locked = True
Me!FTU.Locked = True
Else
If Me!BFT & Me!UPT1 & Me!UPT2 <> 0 & Me!IFF = 0 Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = True
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = False
Me!FTU.Locked = True
Else
If Me!BFT & Me!UPT1 & Me!UPT2 & Me!IFF <> 0 & Me!FTU = 0
Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = True
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = False
Else
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = True
End If
End If
End If
End If
End If
End Sub
form. What I am looking for is essentially the ability to check 5 different
controls for data contained within. The controls are for dates that are
tied to a table that records the training completion dates. In an effort to
avoid out-of-sequence training or edits to the data after the initial entry,
I am wanting to put in this code. It essentially enables the field for
putting in data but disables subsequent fields to maintain the training
sequence.
This is what I have so far (and it is *long* down below). At this point, I
cannot seem to get it to work right. It immediately locks down the form
when there are dates in the fields. The only other thing that I can think
of is to have this same VB code for the BeforeUpdate, On_Click and
AfterUpdate events.
Jason Lopez
Private Sub Form_Load()
If Me!BFT = 0 Then
Me!BFT.Enabled = True
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = False
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = True
Else
If Me!BFT <> 0 & Me!UPT1 = 0 Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = True
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = False
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = True
Else
If Me!BFT & Me!UPT1 <> 0 & Me!UPT2 = 0 Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = True
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = False
Me!IFF.Locked = True
Me!FTU.Locked = True
Else
If Me!BFT & Me!UPT1 & Me!UPT2 <> 0 & Me!IFF = 0 Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = True
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = False
Me!FTU.Locked = True
Else
If Me!BFT & Me!UPT1 & Me!UPT2 & Me!IFF <> 0 & Me!FTU = 0
Then
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = True
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = False
Else
Me!BFT.Enabled = False
Me!UPT1.Enabled = False
Me!UPT2.Enabled = False
Me!IFF.Enabled = False
Me!FTU.Enabled = False
Me!BFT.Locked = True
Me!UPT1.Locked = True
Me!UPT2.Locked = True
Me!IFF.Locked = True
Me!FTU.Locked = True
End If
End If
End If
End If
End If
End Sub