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
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
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
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

Similar threads

Top