populating listbox on custom form from Access

Status
Not open for further replies.

DAVID POWELL

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Outlook 2010
Access 2010 vba

I have a custom form that contains a Listbox and i need to fill it from access vba code:

rsArray = rst.GetRows

Set lstDetailData = objItem.GetInspector.ModifiedFormPages("DsmEmail").Controls("lstDetailData")
lstDetailData.List = rsArray

This is not working..

was also trying:
With objItem.GetInspector.ModifiedFormPages("DsmEmail").Controls("lstDetailData")
.Clear
.ColumnCount = rst.Fields.Count
.Column = rsArray
.ListIndex = -1
.ColumnWidths = "50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt"
Do
.AddItem rst.Fields(0)
.AddItem rst.Fields(1)
rst.MoveNext
Loop Until rst.EOF
End With

Does not work:
Thanks
David Powell
 

DAVID POWELL

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Here are my properties for the Listbox on the Custom Outlook form..
Listbox fields properties10-2-2017 11-13-05 AM.png


I actually only have 9 fields.
so the original post is incorrect with the column widths
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Do either of your attempts work if the listbox is in Access? The same basic code should work in Outlook.
I thought (but have not tested it) that you do something like this to fill fields using an array:
Set objPage = objItem.GetInspector.ModifiedFormPages("DsmEmail") objPage.Controls("lstDetailData").List() = rsArray

(you want to avoid using too many dots - assign object / variable names instead)
 

DAVID POWELL

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Do either of your attempts work if the listbox is in Access? NO
Still not working, but.
The Column Count for the Listbox..Should be 9 because i have nine fields in the query. ? as shown above.
and my column widths are ok ?
I know the array has data because i was running a small bit of code to double check.

rsArray = rst.GetRows(countme)
rst.MoveFirst
Set objPage = objItem.GetInspector.ModifiedFormPages("DsmEmail").objPage.Controls("lstDetailData").List() = rsArray
 

DAVID POWELL

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
also,
trying this and setting my listbox accordingly:

It will only load one column.

With objControlu
do
.AddItem
.List(j, 0) = rs1.Fields(0)
.List(j, 1) = rs1.Fields(1)
j = j + 1
rs1.MoveNext
loop until rs1.eof
End With
 

DAVID POWELL

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
This part is from a command button on the outlook custom form:
This is only loading one field

and i have the column count to 2
and column width 10 pt;10 pt

also,
trying this and setting my listbox accordingly:

It will only load one column.
j = 0
With objControlu
do
.AddItem
.List(j, 0) = rs1.Fields(0)
.List(j, 1) = rs1.Fields(1)
j = j + 1
rs1.MoveNext
loop until rs1.eof
End With
 

DAVID POWELL

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
ok, I had to place the code on the outllok custom form itself and pull the data in from a sql connection to sql server. and then did this:
Set objControlu = objPage.Controls("ListBox2")
objControlu.ColumnCount = 4
objControlu.ColumnWidths = "30 pt;30 pt;30 pt;30 pt;30 pt"

j = 0
With objControlu
do
.AddItem
.List(j, 0) = rs1.Fields(0)
.List(j, 1) = rs1.Fields(1)
.List(j, 2) = rs1.Fields(2)
.List(j, 3) = rs1.Fields(3)


j = j + 1
rs1.MoveNext
loop until rs1.eof
End With

I changed all the properties to the default settings after placing a listbox on the form.

BUT

i still cant get the code to work from access: with this update:

Set lstDetailData = objItem.GetInspector.ModifiedFormPages("DsmEmail").Controls("lstDetailData")

With lstDetailData
.Clear
.ColumnCount = 1
.ColumnWidths = "50 pt ';50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt;50 pt"
z = 0
Do
.AddItem
.List(z, 0) = rst.Fields(0)
' .List(z, 1) = rst.Fields(1)
' .List(z, 2) = rst.Fields(2)
' .List(z, 3) = rst.Fields(3)
' .List(z, 4) = rst.Fields(4)
' .List(z, 5) = rst.Fields(5)
' .List(z, 6) = rst.Fields(6)
' .List(z, 7) = rst.Fields(7)
' .List(z, 8) = rst.Fields(8)

z = z + 1
rst.MoveNext

Loop Until rst.EOF
End With
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T Populating listbox with MS Access table Using Outlook 2
T populating multiple calendars without invites Using Outlook 1
microsvc Populating everyone's calendar with campus events Exchange Server Administration 1
S Custom field not populating in Custom View or Mail Merge Exchange Server Administration 2
B Populating Additional Outlook Column with Date \ Time Using Outlook 0
O Reply and Reply All not populating the To: field Using Outlook 5
R My email merge/business contact manager fields are not populating BCM (Business Contact Manager) 1
V populating worksheet with Outlook mail Outlook VBA and Custom Forms 2
T populating fields with information from the address book Outlook VBA and Custom Forms 5
M BCM History 'From' field not populating BCM (Business Contact Manager) 2
O VBA Cases with Listbox - Can you use Multi-Select? Outlook VBA and Custom Forms 4
A Populate Listbox from Txt File Outlook VBA and Custom Forms 0
A Multi-select Listbox Outlook VBA and Custom Forms 6
K Selecting a folder from an entry in a Listbox Outlook VBA and Custom Forms 1
G How to Copy Multi Select Listbox Data to Appointment Outlook VBA and Custom Forms 3
Diane Poremsky Outlook VBA: Use a Text File to Populate a ListBox New Slipstick.com Articles 0
F Adding textbox filter to listbox? Outlook VBA and Custom Forms 2
G Colors in Listbox Outlook VBA and Custom Forms 2
T Listbox bound Outlook VBA and Custom Forms 6
S Custom Field Cannot Be Displayed In Views Outlook VBA and Custom Forms 2
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
F Validation on custom task form after task acceptance Outlook VBA and Custom Forms 1
K UDF with formula not showing on Calendar custom view. Outlook VBA and Custom Forms 0
S Create a clickable custom column field Outlook VBA and Custom Forms 0
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
M VbScript for Command Button on Contacts Custom Form Using Outlook 1
G Other users can't see P.2 with custom fields in Form Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
S Reference Custom Fields with VBA Outlook VBA and Custom Forms 2
L Custom Form Tutoral? Outlook VBA and Custom Forms 6
D Lost Access to Custom Form Outlook VBA and Custom Forms 4
M vCard does not have user-defined fields from my custom contact form (365) Using Outlook 1
S Outlook Custom Form Scripting only working when clicking on "Run this form" Outlook VBA and Custom Forms 2
A Custom VBA to sort emails into folders Outlook VBA and Custom Forms 0
Victor_50 Outlook 2013 Custom Contact Form starts with "E-mail 2" Outlook VBA and Custom Forms 2
C Custom Form (seperate layout pages and message reading pane) Outlook VBA and Custom Forms 0
C Reading Pane for Custom Form Outlook VBA and Custom Forms 2
M Custom Calendar Print Suggestions? Using Outlook 0
K Custom Category Colors Using Outlook 2
N Custom Form Controls Not Visible To Recipient Outlook VBA and Custom Forms 3
E To convert imported data to custom fields in Task list Outlook VBA and Custom Forms 1
Randy Redekopp How To Merge Contact Info to Email Custom Form Template Using Outlook 2
D Problem with custom form including _DocSiteControl1 Outlook VBA and Custom Forms 0
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
H Custom Signature Not Displayed When Account Selected Outlook VBA and Custom Forms 10
E Custom formula for columns Using Outlook 3
W Message class changes of a custom form changes to the default form Using Outlook 2
A Possible to hide ribbon with custom appointment form? Outlook VBA and Custom Forms 3
S Custom Form, copy user field data to message body Outlook VBA and Custom Forms 12
Andrew Quirl Custom form to route requests based on input criteria Outlook VBA and Custom Forms 1

Similar threads

Top