B
biganthony via AccessMonster.com
Hi,
I have three questions related to an issue I am working through with someone.
I list them below but will provide information about the issue.
I am currently helping some one with an Access 2003 DB that helps her store
the classes needed for a college timetable. I am hoping to provide her with
an opportunity to create some classes in bulk and append them to an existing
table. She has a number of tables representing the faculties eg math, history,
social_science, all with the same structure.
In the math table, classes could appear as: 9matha, 9 mathb, 9mathc or
11math1, 11math2, 11math3 etc
Instead of creating each class individually in the math table, I thought I
could help her create a form where she enters the minimum details and have
Access create the classes and append the 'a', 'b' , 'c' or whatever suffix to
the class name.
This is what I did so you can help me (so bear with me - thanks!):
I created an unbounded form with an option group listing her faculties. The
user chooses the faculty they want to create classes for and this
automatically enters the faculty into the faculty field. This is then used to
determine what faculty table to append the data to (see code below)
I then created unbounded fields that correspond to the number of fields in
her faculty tables. These fields are as follows: ClassID (autonumber),
YearGroup, ClassPrefix, Faculty, Teacher, LessonValue. The class field in her
faculty tables is set to no duplicates as there cannot be two classes called
the same thing in the same college year level.
I then created an unbounded text box called: "number of classes to create"
(NumberToCreate). I am setting this to a maximum of 10.
I then created ten textboxes that will hold one character that represents the
suffix to attach to the end of the class name entered above. In these boxes,
the user would enter 'a', or 'b' or 'c' or '1' or '2' or '3' etc and this
would be attached to the class to produce the class name matha, mathb, mathc,
math1, math2 etc
So, if she wanted to create the math classes for year group 11, she would
enter a value for the autonumber, the year group level, eg 11, the class
prefix, eg 11math, the faculty is automatically entered from the option group
and she could leave the teacher field blank and enter a lesson value. So the
test data could be something like: 140, 11, 11Math, Math, , 10. In the
suffixes textboxes, she could enter the values A,B,C,D,E,F that would be
appended to the class '11Math' to create the unique classes.
So I created a command button on the form and with the help of this forum,
found and added the following code:
****************************************
Dim db As dao.Database
Dim rs As dao.Recordset
Dim NumberofClasses As Integer
Dim Table_Name As String
Table_Name = Me.Faculty
Set rs = DBEngine(0)(0).OpenRecordset(Table_Name, dbOpenTable,
dbAppendOnly)
For NumberofClasses = 1 To Me.NumberToCreate
rs.AddNew
rs.Fields("ClassID") = Me.ClassID
rs.Fields("YearGroup") = Me.YearGroup
rs.Fields("Class") = Me.ClassPrefix + Suffix <<-------- I
Need Help Here !!!!!! *****
rs.Fields("Faculty") = Me.Faculty
rs.Fields("Teacher") = Me.Teacher
rs.Fields("LessonValuel") = Me.LessonValue
rs.Update
Me.ClassID = Me.ClassID.Value + 1
Next NumberofClasses
rs.Close
Set rs = Nothing
*************************************************
My three problems are:
How do I get Access to add the suffix to the Class prefix to produce the full
class name eg 11MathA, 11MathB, 11MathC etc as it goes through the loop above?
?
How do I determine that the autonumber value for classID that the user enters
in the form above is not already used in the destination table? Or, how can I
design it so the user does not have to enter a value for classID field - they
could leave it blank and Access could append the data and automatically
continue the autonumber sequence in the table?
If the user wants ten classes created in bulk, I would like to have all ten
suffix text boxes enabled. If the user only wants four classes created, how
do I enable the first four text boxes and disable the other six etc? I am
sure the answer involves looping through the ten textbox controls and setting
their enabled values to true/false, but i have no idea how to write that code.
I appreciate any advice and thank you in advance.
regards
Anthony
I have three questions related to an issue I am working through with someone.
I list them below but will provide information about the issue.
I am currently helping some one with an Access 2003 DB that helps her store
the classes needed for a college timetable. I am hoping to provide her with
an opportunity to create some classes in bulk and append them to an existing
table. She has a number of tables representing the faculties eg math, history,
social_science, all with the same structure.
In the math table, classes could appear as: 9matha, 9 mathb, 9mathc or
11math1, 11math2, 11math3 etc
Instead of creating each class individually in the math table, I thought I
could help her create a form where she enters the minimum details and have
Access create the classes and append the 'a', 'b' , 'c' or whatever suffix to
the class name.
This is what I did so you can help me (so bear with me - thanks!):
I created an unbounded form with an option group listing her faculties. The
user chooses the faculty they want to create classes for and this
automatically enters the faculty into the faculty field. This is then used to
determine what faculty table to append the data to (see code below)
I then created unbounded fields that correspond to the number of fields in
her faculty tables. These fields are as follows: ClassID (autonumber),
YearGroup, ClassPrefix, Faculty, Teacher, LessonValue. The class field in her
faculty tables is set to no duplicates as there cannot be two classes called
the same thing in the same college year level.
I then created an unbounded text box called: "number of classes to create"
(NumberToCreate). I am setting this to a maximum of 10.
I then created ten textboxes that will hold one character that represents the
suffix to attach to the end of the class name entered above. In these boxes,
the user would enter 'a', or 'b' or 'c' or '1' or '2' or '3' etc and this
would be attached to the class to produce the class name matha, mathb, mathc,
math1, math2 etc
So, if she wanted to create the math classes for year group 11, she would
enter a value for the autonumber, the year group level, eg 11, the class
prefix, eg 11math, the faculty is automatically entered from the option group
and she could leave the teacher field blank and enter a lesson value. So the
test data could be something like: 140, 11, 11Math, Math, , 10. In the
suffixes textboxes, she could enter the values A,B,C,D,E,F that would be
appended to the class '11Math' to create the unique classes.
So I created a command button on the form and with the help of this forum,
found and added the following code:
****************************************
Dim db As dao.Database
Dim rs As dao.Recordset
Dim NumberofClasses As Integer
Dim Table_Name As String
Table_Name = Me.Faculty
Set rs = DBEngine(0)(0).OpenRecordset(Table_Name, dbOpenTable,
dbAppendOnly)
For NumberofClasses = 1 To Me.NumberToCreate
rs.AddNew
rs.Fields("ClassID") = Me.ClassID
rs.Fields("YearGroup") = Me.YearGroup
rs.Fields("Class") = Me.ClassPrefix + Suffix <<-------- I
Need Help Here !!!!!! *****
rs.Fields("Faculty") = Me.Faculty
rs.Fields("Teacher") = Me.Teacher
rs.Fields("LessonValuel") = Me.LessonValue
rs.Update
Me.ClassID = Me.ClassID.Value + 1
Next NumberofClasses
rs.Close
Set rs = Nothing
*************************************************
My three problems are:
How do I get Access to add the suffix to the Class prefix to produce the full
class name eg 11MathA, 11MathB, 11MathC etc as it goes through the loop above?
?
How do I determine that the autonumber value for classID that the user enters
in the form above is not already used in the destination table? Or, how can I
design it so the user does not have to enter a value for classID field - they
could leave it blank and Access could append the data and automatically
continue the autonumber sequence in the table?
If the user wants ten classes created in bulk, I would like to have all ten
suffix text boxes enabled. If the user only wants four classes created, how
do I enable the first four text boxes and disable the other six etc? I am
sure the answer involves looping through the ten textbox controls and setting
their enabled values to true/false, but i have no idea how to write that code.
I appreciate any advice and thank you in advance.
regards
Anthony