Minggu, 17 September 2017

Re: [MS_AccessPros] Dynamically create a listbox in vba

 

Private Sub Form_Load()
  On Error GoTo EHTLR
    'Set TDBList1.RowSource = Adodc1.Recordset
    Me.TDBList1.Column(16).Visible = False
   
    Me.TDBList1.Column(2).Style.Font.Bold = True
    Me.TDBList1.Column(2).Style.BackColor = &H80000018
    Me.TDBList1.Column(2).HeadingStyle.Font.Bold = True
'    TDBList1.ColumnHeaders = False
   
'    For i = 1 To 9
'        If TDBList1.Columns(i + 2).Text = "IndexKey0" & i Then TDBList1.Columns(i + 2).Text = ""
'    Next i
'    If TDBList1.Columns(12).Text = "IndexKey10" Then TDBList1.Columns(12).Text = ""
   
   
' Hiding some columns
    Me.TDBList1.Column(16).Visible = False
    Me.TDBList1.Column(17).Visible = False
    Me.TDBList1.Column(19).Visible = False
    Me.TDBList1.Column(20).Visible = False
    Me.TDBList1.Column(21).Visible = False
   
' setting column caption and the size:
'    TDBList1.Columns(0).Width =
    Me.TDBList1.Column(0).Caption = "eFolder"
    Me.TDBList1.Column(1).Caption = "eSubFolder"
    Me.TDBList1.Column(2).Width = 3000
    Me.TDBList1.Column(13).Caption = "Type"
    Me.TDBList1.Column(13).Width = 450
    Me.TDBList1.Column(14).Width = 980
    Me.TDBList1.Column(14).TextAlign = 1

    Me.TDBList1.Column(15).Width = 980
    Me.TDBList1.Column(15).Alignment = 1
    Me.TDBList1.Column(17).Caption = "Size(Bytes)"
    Me.TDBList1.Column(17).Width = 850
    Me.TDBList1.Column(17).Alignment = 3
    Me.TDBList1.Column(18).Width = 840
    Me.TDBList1.Column(18).Alignment = 1
   
   
EHTLR:
    MsgBox "Error: " & Err.Number & "--" & Err.Description, , "Form_Load"
   
End Sub


But I end up with a object not found error when I run it....


SELECT tblMainTitle.MainLevelTitle, tbleSubFolderTable.SubLevelOneName, tblDocument.DocumentName, tblMainTitle.IndexKey01, tblMainTitle.IndexKey02, tblMainTitle.IndexKey03, tblMainTitle.IndexKey04, tblMainTitle.IndexKey05, tblMainTitle.IndexKey06, tblMainTitle.IndexKey07, tblMainTitle.IndexKey08, tblMainTitle.IndexKey09, tblMainTitle.IndexKey10, tblDocument.DocumentFileType, tblDocument.CreatedDate, tblDocument.CreatedTime, tblDocument.DocumentLocation, tblDocument.DocumentFileKBSize, tblDocument.DocGroup, tblMainTitle.MainTitleKey, tblDocument.SubLevelOneKey, tblDocument.DocumentKey
FROM (tblMainTitle LEFT JOIN tblDocument ON tblMainTitle.MainTitleKey = tblDocument.MainTitleKey) LEFT JOIN tbleSubFolderTable ON tblDocument.SubLevelOneKey = tbleSubFolderTable.SubLevelOneKey;

Sorry, Here is the SQL for the query rowsource...:

And as I looked around and I found this for adding properties for a list box so I played with it and came up with this:




With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"






On ‎Saturday‎, ‎September‎ ‎16‎, ‎2017‎ ‎04‎:‎18‎:‎49‎ ‎PM, crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


 

hi Art,

make a query and assume the value of each of those checkboxes by using True or False in criteria for the query. Once you have done that, let us know what the SQL is and we can help you with the VBA to get there.

have an awesome day,
crystal

On 9/16/17 3:02 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] wrote:
There is three checkboxes on another form called frmMain which are set when a user completes a series of actions. However those checkboxes are set will determine the rowsource of the list box on frmDocument list.


With Warm Regards,
 
Arthur D. Lorenzini
IT System Manager
Cheyenne River Housing Authority
Wk.(605)964-4265  Ext. 130
Fax (605)964-1070

"Valar Dohaeris"






On ‎Saturday‎, ‎September‎ ‎16‎, ‎2017‎ ‎02‎:‎48‎:‎52‎ ‎PM, crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


 

hi Art,

yes, the RowSource of a combobox or listbox can be created with code.

The first step would be to make a query that shows the data you want. Then copy its SQL and modify (or create) the WHERE clause with VBA and make that the RowSource.

How will this be triggered?

have an awesome day,
crystal

On 9/16/17 1:47 PM, dbalorenzini@yahoo.com [MS_Access_Professionals] wrote:


Can you create and populate a listbox control dynamically using vba?

Thank you,

Art Lorenzini
SD


__._,_.___

Posted by: Art Lorenzini <dbalorenzini@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (6)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar