if one student will enroll in one section (section galatia)den if the staff will click save button den if its done. then another student will enroll den another section (section israel) will be use.
Ok, I will try and figure this out with your help please.
What exactly is the sections you are mentioning here? Is it different "areas" within the school? If so, then you will create a database table named "Galatia", another table called "Isreal" and so on for each section or area. If not, please try and explain the "section" concept please. Your fields within the table will be something like "StudentId", StudentName", Student... and so on.
Once the tables are created, you will connect your application to the database and then save each student into its respective area or section.
Am I on the right path here with my assumptions?
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Ok,
First we create the table 'SectionEntry' with a field called 'Section'
To add a new section (assuming that you will be using MS Access as database tool), we will do the following -
Reference the MS ActiveX Dataobjects 2.x under references
Option Explicit
Private WithEvents cnSectionEntries As ADODB.Connection
Private WithEvents rsSectionEntries As ADODB.Recordset
Private Sub Form_Load()
Set cnSectionEntries = New ADODB.Connection
cnSectionEntries.CursorLocation = adUseClient
'Open database connection
cnSectionEntries.Open "provider = microsoft.jet.oledb.4.0;persist security info=false;data source =" & App.Path & "\School.mdb"
'School is the Access Database you created
End Sub
Private Sub Command1_Click ()
Set rsSectionEntries = New ADODB.Recordset 'Set new recordset
rsSectionEntries.Open "SELECT Section FROM SectionEntry", cnSectionEntries, adOpenStatic, adLockOptimistic 'Open the table
rsSectionEntries.AddNew 'Tell database that a new record is to be added
rsSectionEntries!Section = Text1.Text 'New section name to database from textbox.
rsSectionEntries.Update 'Save new entry
'Close recordset
rsSectionEntries.Close
End Sub
Private Sub Form_Unload()
'Close the database connection
cnSectionEntries.Close
End Sub
Now we need to get all the sections in a room into a combobox. This is the easiest way to let a user rather select the sections already available than to guess what section to add. When they add a new student, the correct section will be assigned -
Private Sub LoadCombo ()
Dim RecCount As Integer
Set rsSectionEntries = New ADODB.Recordset 'Set new recordset to load combo
rsSectionEntries.Open "SELECT Section FROM SectionEntry", cnSectionEntries, adOpenStatic, adLockOptimistic 'Open the table
If rsSectionEntries.BOF Or rsSectionEntries.EOF = True Then
'No records available to load.
'Add code here to let user know that no data is available like -
MsgBox "No data to select from.", vbOkOnly + vbInformation, "No Data"
Else
rsSectionEntries.MoveFirst
For RecCount = 0 To rsSectionEntries.Recordcount
Combo1.AddItem rsSectionEntries!Section
rsSectionEntries.MoveNext
Next RecCount
End If
'Close recordset
rsSectionEntries.Close
Private Sub Combo1_Click ()
Call LoadCombo
End Sub
When the user now click on the combobox, you can take that data and save it into the students record. The following is only a sample. I am sure this will help you to complete the project succesfull.
Text1.Text = Combo1.Text
Good luck....
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
No problem, just add a field to your Table "SectionEntry" named "StudentLevel" or whatever name you wish. Just add the data when you add the section data -
rsSectionEntries!Section = Text1.Text 'New section name to database from textbox.
rsSectionEntries!StudentLevel = Text2.Text 'Add the student level
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
It was a pleasure. If this has solved your problem, please mark as solved.
As far as DB2 is concerned, I am not to clued up on its workings, but the basics will be ths same. Just make sure that your connection to the database is correct.
Good luck in finishing it off soon
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350