Advertisement

02.20.2007 at 08:15PM PST, ID: 22402727
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

Populate ListView From View/Sql MS ACCESS 2003 MSSQL ADP

Asked by Y2Kingswood in Microsoft ADP, SQL Query Syntax, Access Coding/Macros

Tags: , ,

Any idea how i would populate the contents of a ListView control with the results of an Sql String?

example:
Function PopulateListView(Sql As String, LV As Object)
Usage:
PopulateListView("Select * from Student_T Where StudentId = 5607423", Me!StudentListView)

I had an exmaple of this, but it would only work in and MDB if anyone would like to update it to code that would work with and ADP that would be great. (although it wouldnt take SQL only a Table/Query Name).

MDB CODE:

Option Explicit

Function FillList(Domain As String, LV As Object) As Boolean
      '==================================================================
      '  Purpose:   to fill a ListView control with data from a table or
      '             query
      '  Arguments: a Domain which is the name of the table or query, and
      '             a ListView control object
      '  Returns:   A Boolean value to indicate if the function was
      '             successful
      '==================================================================

      Dim db As Database, rs As Recordset
      Dim intTotCount As Integer
      Dim intCount1 As Integer, intCount2 As Integer
      Dim colNew As ColumnHeader, NewLine As ListItem

      On Error GoTo Err_Man

      ' Clear the ListView control.
      LV.ListItems.Clear
      LV.ColumnHeaders.Clear

      ' Set Variables.
      Set db = CurrentDb
      Set rs = db.OpenRecordset(Domain)


      ' Set Column Headers.
      For intCount1 = 0 To rs.Fields.Count - 1
         Set colNew = LV.ColumnHeaders.Add(, , rs(intCount1).Name)
      Next intCount1
      LV.View = 3    ' Set View property to 'Report'.

      ' Set Total Records Counter.
      rs.MoveLast
      intTotCount = rs.RecordCount
      rs.MoveFirst

      ' Loop through recordset and add Items to the control.
      For intCount1 = 1 To intTotCount
         If IsNumeric(rs(0).Value) Then
            Set NewLine = LV.ListItems.Add(, , Str(rs(0).Value))
         Else
            Set NewLine = LV.ListItems.Add(, , rs(0).Value)
         End If
         For intCount2 = 1 To rs.Fields.Count - 1
            NewLine.SubItems(intCount2) = rs(intCount2).Value
         Next intCount2
         rs.MoveNext
      Next intCount1

      Exit Function

Err_Man:
         ' Ignore Error 94 which indicates you passed a NULL value.
         If Err = 94 Then
            Resume Next
         Else
         ' Otherwise display the error message.
            MsgBox "Error: " & Err.Number & Chr(13) & _
               Chr(10) & Err.Description
         End If

      End Function
Start Free Trial
 
Loading Advertisement...
 
[+][-]02.20.2007 at 08:26PM PST, ID: 18576272

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft ADP, SQL Query Syntax, Access Coding/Macros
Tags: access, listview, 2003
Sign Up Now!
Solution Provided By: LPurvis
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.20.2007 at 08:59PM PST, ID: 18576368

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.20.2007 at 09:03PM PST, ID: 18576380

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02.20.2007 at 10:13PM PST, ID: 18576600

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2007 at 12:15AM PST, ID: 18576835

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2007 at 01:47PM PST, ID: 18582532

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2007 at 02:00PM PST, ID: 18582637

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32