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
 
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
 
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)
 
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
 
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
 
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
 
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
 
i still cant get the code to work from access:

how are you referencing the outlook object model? Are you using early or late binding?
Can you post the full code?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
T Populating listbox with MS Access table Using Outlook 2
A Outlook Reminders not populating for certain events 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
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
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
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 Using Outlook 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
G Apply Custom Contacts form to all existing Contacts Outlook VBA and Custom Forms 1
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
G Outlook 2021 Add Picture to Custom Contact Form Outlook VBA and Custom Forms 2
X Custom icon (not from Office 365) for a macro in Outlook Outlook VBA and Custom Forms 1
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
AndyZ Contact Custom Form Tiny Text Outlook VBA and Custom Forms 3
A How to reduce size of custom contact form? Outlook VBA and Custom Forms 3
S Custom Contact card - need help creating one Outlook VBA and Custom Forms 1
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
S Adding Custom Forms Outlook VBA and Custom Forms 4
Witzker How to get the button Karte ( map) in custom contact form Outlook VBA and Custom Forms 2
B Outlook 2019 Custom Email form - Edit default email form Outlook VBA and Custom Forms 6
D Outlook 365 Custom forms field limit? Outlook VBA and Custom Forms 4
J PSA: How to create custom keyboard shortcut for "Paste Unformatted Text" in Outlook on Windows Outlook VBA and Custom Forms 1
M copy field value to custom field Outlook VBA and Custom Forms 0
J Does the .fdm contain my custom form? How to make ol use it? - ol2007 Outlook VBA and Custom Forms 4
J ol2021 custom form not displaying pics Outlook VBA and Custom Forms 37
N "Perform a Custom Action" Outlook VBA and Custom Forms 0
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
C Create Meeting With Custom Form Outlook VBA and Custom Forms 2
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
J custom form not displaying pictures Outlook VBA and Custom Forms 7
I Button PDF in Outlook Contact custom form Outlook VBA and Custom Forms 1
K Font Sizing in Custom Form Regions for Contacts Outlook VBA and Custom Forms 1
V Update new custom field Outlook VBA and Custom Forms 5
D Anyone tell me where custom view settings are stored? Outlook VBA and Custom Forms 9
S Outlook 2016 Arrange tasks by date, additional custom sorting, but still use friendly terms like Today, Tomorrow, This week? Using Outlook 1
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
H Custom Outlook Contact Form VBA Outlook VBA and Custom Forms 1
S Custom Field Cannot Be Displayed In Views Outlook VBA and Custom Forms 2

Similar threads

Back
Top