Log in

View Full Version : Solved: Creating array of values from dynamic listbox values



Movian
04-27-2009, 06:21 AM
Hey,
i have a listbox that can have between 1 and 20 values. Each value directly relates to an individual record (From a lookup table). This allows for the user to be easily able to switch between records on the form by double clicking on an option.

Now when the user has finished entering their data into the diffrent records, i need to be able to search through each record and grab data that i need. I thought the best way to do this (as i can't use Index and seek on this particular table, and going through each record via DAO and adding ID's to a list would take too long) that i could simply go through each item that is in the listbox (Generated through a Mysql statement) THe list box has two fields. a hidden field in column 1 (Autonumber ID field). and a second column that has an integer denoting the number of the record for a given Patient. (the problem being i normally use a patient ID as a Primary key however this is a one to many relationship so a patient can have multiple records, so i have three fields, ID, Patientrecordnum, PatientID)


So after explaning the situation i need a way to loop through each item in my listbox and add the first coumn value to a list. Alternativly if i can SELECT each option i could turn screen echo off and simply select each option on the form and then grab the info of the form instead of VIA DAO.

As always any help is apriciated :)

Movian
04-27-2009, 08:23 AM
After searching around for a couple more hours i found a usable solution!

Dim SQLString As String
SQLString = "SELECT vesselID, SiteNumber FROM MultiVesselAblPopUp WHERE PatID ='" & Forms("frmMain").MedicalID & "' ORDER BY vesselID ASC"

Set myrs = CurrentDb().OpenRecordset(SQLString)

Didn't realize you could open a Dao Record Source with a SQL qualifier to give you a smaller record set!!! that's Damn useful.