Find/Compare/Select from Textbox to Multivalue Listbox *Unselected*

123noob

New member
Local time
Yesterday, 23:19
Joined
Jun 17, 2017
Messages
2
Hi all, I new and still learning/venturing in the field of programming. Access is fun as it's easy for me to play around with for learning.

Currently I am stumped in searching for a solution that I have been trying to search for but no luck... probably due to me not doing the correct search. My problem right now is with multivalue (simple/extended) listbox and hope to find a solution to this.

There are 2 forms involved in this process, both are unbound.

FrmA - contain simple listbox for all records viewing. (The tables are stored in a SQL server)

With FrmA listbox on doubleclick a record > go to > FrmB (unbound) to view the record in detail [let's say there are 4 fields total: ReferenceNum, TaskSubject, CaseDocket, FiledByDocket]

All are using unbound textbox fields. In addition, FiledByDocket unbound textbox field is dependent on a listbox with multivalue (in order to select multiple names separated by ", " when inserting into the textbox)

Right now there is no issue with FrmB, the issue is when FrmA opening the record and trying to reference the textbox of FiledByDocket to the listbox.

If the value in FiledByDocket textbox field contains when the form is loaded with selected record from FrmA: NameA, NameC, NameE, I want the listbox to automatically select the same values that is from the FiledByDocket textbox field.

- The listbox values are: 'NameA','NameB','NameC','NameD','NameE'

I created a module for FrmA to call to in order to split the values in the textbox once FrmB is loaded with the delimiter ", " and got that part working.

Code:
' for FrmA to call on
public sub valListName()
[INDENT]dim strName, strArray as string
dim varArray as variant

strName = [forms]![mainform]![child1]![FiledByDocket].value
strArray = split(strName, ", ")

For each varArray in strArray
[INDENT]' so here is what I'm looking for for the code to search/compare the varArray to the
' unselected listbox and go through it so that way it ends up with valid index of the value where it equals to the value from that array.
'
' Then do listbox.selected(that_index) = true[/INDENT]
next

' if I do debug.print varArray within the For...Next I get the text values which is what I wanted to use to compare with the listbox without having to select it.[/INDENT]
End Sub
I hope my question is valid and thank you so much for your help. Please let me know if I need to provide any additional information.

Again, please excuse my poor use of vocabularies.
 

Users who are viewing this thread

Back
Top Bottom