creating new record from a listbox

nebakanezzar

Member
Joined
Apr 2, 2010
Messages
6
Programming Experience
Beginner
Hey All,

I am new to VB, and in need of a little assistance. My goal is to create new training employee records, so far I am populating a listbox with employee names from the employee table (in access), using the following code:

Dim intAdd As Integer
For intAdd = 0 To lstName.Items.Count - 1
If lstName.GetSelected(intAdd) = True Then
lstAdd.Items.Add(lstName.Items(intAdd))
End If
Next intAdd

Here is where I am having the difficulty. From here I would like to select the employees who attended the training, and then using a button click event, create a subform with a list of the selected employees and a text box next to each name to capture the dates they attended the training. From here I want to create new training records using the employees employee number from the employee table as part of the primary key for the training record table.


neb.
 
Read the DW3 link in my signature, section "Creating a Simple Data App"
That will get you to a point where you have a list of names in a grid on screen (I know you think you have this currently, but the tutorial is more about getting you to do your data access in a modern fashion)

Then:
Add a boolean column called IsPresent to the DataTable in the dataset, and add it to the datagridview columns collection. Remove the uninteresting columns
Create a tableadapter and datatable linked to your other table (where you record attendance)
In your code create an instance of both
Run a loop that:
>uses the datatable.Select("[isPresent] = TRUE") method to return an array of datarows
>loop through them adding a new record to the attendance datatable, using the row of the present person (for their ID etc) and getting the date from a date picker (not textbox)
>when your loop finishes you'll have a datatable with people and dates. use the tableadapter to uplaod it to the database

Use:
The user runs the program and sees a list of names and tickboxes
He ticks everyone who is present and sets the datepicker
He clicks the "record attendance" button and the ticked people are written to the database


You didnt say much about your dsatabase structure, so this assumes you have:

tblPeople
PersonID
Name

tblAttendance
PersonID
CourseID
AttendDate


If you have some kind of horizontal structure:

PersonID
CourseDay1Date
CourseDay2Date
CourseDay3Date
...

You might choose to just show them all in a grid

-
Avoid listbox; showing lists of info with a grid offers much more flexibility and functionality
 
Back
Top