Senin, 18 September 2017

Re: [MS_AccessPros] Dynamically create a listbox in vba

 

hi Art,

thanks ... but I do not see any criteria -- ie: the yes/no controls you said were important?

questions:

1. Where did this application come from?

2a. And why is it now on your plate? 2b. What is your role in this process?  2c. Why is is not being left in VB?

3. What happened to the Yes/No values that are driving things?

4a. and what about restructuring to make it better as it is being converted? (I replied to your first message when you posted the SQL because the numbered fields contain like information) ... 4b.  and why is it being converted to Access since VB still works? This is a huge task requiring advanced developer skills!

5. What is the purpose?

thanks, Art

have an awesome day,
crystal

On 9/18/17 3:29 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] wrote:
You must have missed a email. But here are the responses:

To answer your questions, first, the fields IndexKey01, IndexKey02, ... IndexKey10 is a misleading name. THe field contains field names. Given the type of document coming in these fields may for example contain something like IndexKey01 = CustomerName, IndexKey02= Address, IndexKey03=Phone, etc. or if the document is invoice they could be  IndexKey01 = InvoiceDate, IndexKey02= Invoice Number, IndexKey03=CustomerName, etc. The process goes like they enter this information and then either hit a scan button or a import button which brings the document into the system and assigns these search values...

The coding is VB6 from back about 2007.

The control is a VB6 picture box.....

This is the query I created based on the VB code:

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;



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 ‎Monday‎, ‎September‎ ‎18‎, ‎2017‎ ‎10‎:‎49‎:‎46‎ ‎AM, crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


 

hi Art,

please answer all the questions ... and make your own query to get the data, thanks!

have an awesome day,
crystal

On 9/18/17 8:37 AM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] wrote:
I forgot...
The control is a picturebox (I have no idea why they would use that).

and the actual select statement from the vb6 code::
 

With Adodc1
        .ConnectionString = connectionStrg
        .RecordSource = "SELECT MainTitle.MainLevelTitle, eSubFolderTable.SubLevelOneName, " & _
            "Document.DocumentName, MainTitle.IndexKey01, MainTitle.IndexKey02, " & _
            "MainTitle.IndexKey03, MainTitle.IndexKey04, MainTitle.IndexKey05, " & _
            "MainTitle.IndexKey06, MainTitle.IndexKey07, MainTitle.IndexKey08, " & _
            "MainTitle.IndexKey09, MainTitle.IndexKey10, " & _
            "Document.DocumentFileType, Document.CreatedDate, Document.CreatedTime, " & _
            "Document.DocumentLocation, Document.DocumentFileKBSize, Document.DocGroup, " & _
            "MainTitle.MainTitleKey, Document.SubLevelOneKey, Document.DocumentKey " & _
            "FROM ((MainTitle LEFT JOIN Document ON [MainTitle].[MainTitleKey] " & _
            "=[Document].[MainTitleKey]) LEFT JOIN eSubFolderTable ON [eSubFolderTable].[SubLevelOneKey] " & _
            "=[Document].[SubLevelOneKey]) WHERE MainTitle.ArchiveKey ='" & archiveKey & "'"






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 ‎Sunday‎, ‎September‎ ‎17‎, ‎2017‎ ‎03‎:‎00‎:‎39‎ ‎PM, crystal 8 strive4peace2008@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:


 

hi Art,

the is very confusing. It seems that the data is not normalized as I see fields like IndexKey01, IndexKey02, ... IndexKey10. This is a not a good way to structure the information! The index keys should be in a related table with 0 to however many records are needed. That will make everything so much easier.

Also, the code is confusing -- is this VBA for Access?

What kind of control is being used? AFAIK, List Boxes in Access cannot address column properties like this. While the VB language VB is very much like VBA (Visual Basic for Applications), the normal Access controls are different -- for instance, with list boxes, captions are determined in the Row Source by assigning field aliases, widths are listed in Column Widths using a string delimited with semi-colon, Alignment can only be done using formulas to pad spaces (so, in other words, duct-tape!)

I also do not see the 'placeholder' values for the Yes/No values you mentioned in the SQL -- in fact, there is not even a WHERE clause, so ... did you create the query yourself? 

At any rate, the database needs to be better structured. If this is a conversion, it is best to do that now.

have an awesome day,
crystal


On 9/17/17 1:13 PM, Art Lorenzini dbalorenzini@yahoo.com [MS_Access_Professionals] wrote:

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: crystal 8 <strive4peace2008@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (12)

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