Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A tricky one! => VB Insert Multiple into Access DB

Status
Not open for further replies.

DaveyCrockett

Programmer
Jul 15, 2003
36
US
Hello Everyone,

I have had so much success by posting to Tek-Tips that I thought I would return for another tip.

I am trying to help out a church to assist them in their recordkeeping of class attendence. They currently have the people sign in and keep the sheets filed. I thought it would be best if they had a little VB application that had 3 MS access tables.

tblClasses
tblPeople
tblAttendence

On the input form, I have the date attended as an input (default of NOW()), have a class populated with classes.
When the "data entry clerk" selects the class, I get the attendees who belong to the class (specified in the tblPeople where classID = tblPeople.Class1 or classID = tblPeople.Class2 -- as they can only belong to up to 2 classes)

So, I poplulate a list box with all the People for the selected class with the style set to checkbox. This will allow the clerk to select who attended the class that day then hit a submit button to add all attendees to the tblAttendance table.

My issue is, how do I enter the selected people? How do I tell who is selected? Any assistance would be appreciated and code sample would be SSSS
Thank you all in advance
 
To determine if an attendee is selected you can use the list box .selected property. Just loop through the items in the list box.

I would also use the itemdata property to store the person ID (or key value) so that you can use it when adding to the Attendance table.

When loading the list box,

Code:
...
For i = 0 to <number of people>
  list1.additem <person name>
  list1.itemdata(i) = <person ID>
next i
...

Top extact the selected people,

Code:
...
for i = 0 to list1.listcount-1
  if list1.selected(i) then
     <add to attendance table>
     <ID> = list1.itemdata(i)
  end if
next i
...

That is the list box code in a nut shell. When you get stuck post your code and we will have a look.

zemp
 
You might consider using the DATE function, rather than the NOW function. It will make searches on date much easier, because Now stores date and time

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top