That's quite an If..Then statement you have there.
First of all, IF you have a control disabled THEN I don't see why you need
to lock it also. It seems like alot of extra coding for nothing.
Second, why don't you just set the default value of all the controls on your
form to locked, then just use the code to unlock them as needed.
Third, it seems like this code would be better placed in the on current
event for your form. As it is now, it is only going to run once when your
form first loads. If a user does an update and then moves to a new record
without ever closing the form, your code will do nothing
You also might consider a Select Case statement.
> 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
[quoted text clipped - 91 lines]
> End If
> End Sub
Jason Lopez - 13 Jul 2007 22:14 GMT
I never thought of setting the default to Disabled and then letting the code
as OnCurrent work then. But what do you mean by a "Select Case" statement?
I have never heard of that before. Also, I am not a programmer in any way.
Barely touching the surface of VB at this point. Though I am probably in
way over my head.
Jason Lopez
> That's quite an If..Then statement you have there.
>
[quoted text clipped - 113 lines]
>> End If
>> End Sub
>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
[quoted text clipped - 10 lines]
>of is to have this same VB code for the BeforeUpdate, On_Click and
>AfterUpdate events.
Stepping back a bit... if you have one *field* for each kind of date, you're
perhaps limiting your flexibility in terms of table design. Suppose you want
to add a *sixth* type of training? You'll need to restructure your table,
rewrite all your queries, redesign your forms and reports, rewrite all your
code... ouch!
Could you instead consider a four-table solution:
Employees
EmployeeID <Primery Key>
LastName
FirstName
<other bio data>
Courses
CourseID <Primary Key>
Description
<other info about the training>
Schedule
SeqNo <what order the courses must be taken>
CourseID <which course>
<other info, e.g. comments, valid reasons to take a course out of order or
skip it, etc.>
Trainings
TrainingID
EmployeeID
CourseID
CompletionDate
<comments, pass/fail, retakes, etc.>
You could then simply *add a record* to the Trainings table; the form's
beforeupdate event could be used to ensure that you're not entering a course
out of sequence; it would make reporting MUCH easier.
John W. Vinson [MVP]
Jason Lopez - 13 Jul 2007 22:12 GMT
You are already thinking along the lines that I am wanting to take these
tables and forms.
The training form is actually just a summary of the additional forms that
will contain the greater detail of each phase/step in training.
Essentially, the tables look like this:
Trg-BFT; Trg-UPT1,... There are 5 phases/tables total with the summary
table (TrgProg) as an extra and sub to the main form/table. To complete
each phase, there are varying requirements. An example is that Trg-BFT has
5 requirements that must be met. When requirement 5 is completed, then the
AfterUpdate event will send the current date to TrgProg in its respective
field (and hopefully for the correct person). With all the code existing in
the forms, it should work out to going to the correct person the moment that
the subform is updated.
But, you are essentially saying to make a table that already has the
sequence there? Is that right?
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
[quoted text clipped - 57 lines]
>
> John W. Vinson [MVP]
John W. Vinson - 16 Jul 2007 06:50 GMT
>You are already thinking along the lines that I am wanting to take these
>tables and forms.
[quoted text clipped - 15 lines]
>But, you are essentially saying to make a table that already has the
>sequence there? Is that right?
That's the idea, yes. You can actually create a subform based on a Query "left
outer joining" the requirements table to the results table; if you have this
subform with the person's ID as the master/child link field you don't need
even a single line of code.
John W. Vinson [MVP]
Jamie Collins - 16 Jul 2007 10:38 GMT
On 13 Jul, 21:20, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com>
wrote:
> >a table that records the training completion dates. In an effort to
> >avoid out-of-sequence training
[quoted text clipped - 28 lines]
> CompletionDate
> <comments, pass/fail, retakes, etc.>
But consider that the OP has stated "avoid out-of-sequence training"
as a requirement. I don't see anything in your proposed design to
enforce this. To take a different angle on your "sixth date" argument,
consider these simple validation rules:
Date1 < Date2
Date2 < Date3
Date3 < Date4
Date4 < Date5
Date5 < Date6
How would you achieve the same data integrity with your 'flexible'
design?
Jamie.
--
Jason Lopez - 16 Jul 2007 15:13 GMT
I actually used a hybrid of code (no query worked to do what I was
ultimately looking for).
It essentially resets the properties and then runs the IF statements to
disable the appropriate box. But, thank you Jamie for bringing back my main
point for each field: proper sequencing validation.
Thank you to all that have helped so far. I am not quite done with that
part of my database form. So I am sure I will still have more questions yet
to come.
Jason Lopez
> On 13 Jul, 21:20, John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com>
> wrote:
[quoted text clipped - 50 lines]
>
> --