HELP: Auto Populate Excel Userform fields from access query result
Sam,
Have you considered using a ListBox instead of multiple text boxes? I have
never done an Access query from Excel, so I don't know what the result is
returned as (i.e. an object, a delimited string, etc.); however, I'm sure
that parsing the result will be easy enough.
The VBE Help for "List Property" shows you how this property can be utilized
for a ListBox control. Specifically, you can load the list one item at a
time (via the row/column index), or you can use an array to load the list all
in one shot. If you use the later (i.e. the array approach), then I suggest
setting the ColumnCount property prior to setting the List property. (I've
run into situations where a multi-dimensional array would load correctly into
the List property only if I set the ColumnCount prior to setting the List
property). Take specific note that the row/column numbering begins at zero.
Let me know if this helps (or if you need me to create a dummy Excel to
Access query to determine how to get the query data parsed into the ListBox,
which would force me to learn something that has been on my to-do list).
Best,
Matthew Herbert
"sam" wrote:
Hi All,
How do I populate Access query results in excel userform text fields?
For eg;
I have a Query: "SELECT Student_ID, Course, Grade, Qtr_ID" & _
" FROM Student_Info WHERE Student_ID = " & _
Me.StudentId.Value
Here Me.StudentId.Value is a text box in excel userform
And here is what the query results look like:
Student_ID Course Grade Quarter_ID
JP1124 Math A SP01
SP1164 Phy B SP01
Here "Student_ID, Course, Grade, Quarter_ID" are the column headers in Access
The userform looks like this:
Student ID: [ ]
Course Grade Quarter_ID
[ ] [ ] [ ]
[ ] [ ] [ ]
[ ] [ ] [ ]
So the query results will go into different textboxes [ ]
Hope I made it clear,
Thanks in advance
Thanks in advance
|