Results 1 to 27 of 27

Thread: form activate

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    Post

    One for the guru's i think:
    I have this:

    Dim index As Integer
    If loadedcheck = False Then
    For index = 0 To 5
    If index <> 0 Then
    Load CheckGDW(index)
    CheckGDW(index).Top = CheckGDW(index).Height * index + CheckGDW(index).Top
    End If
    CheckGDW(index).Visible = True
    CheckGDW(index).Caption = "Check box number " & index
    Next index
    loadedcheck = True
    End If

    ...you experts will note that this creates check boxes to the amount specified, what i would like to do is read a mdb file and create the amount of check boxes to the specific text from the mdb file for instance:

    loop until eof
    txtCustomerID = "" & rs!CustomerID
    end

    Many thanks in advance



  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ??

    not sure if I understand this question..
    are you wanting to open up 9 check boxes with their
    caption being the CustomerID field from your database
    assuming there is 9 records in the mdb...5 if 5 etc.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    Is this what you are asking?


    Code:
    '' error handling, not included =)
    
    Dim index  As Long
    Dim m_conn As ADODB.Connection
    Dim rs     As ADODB.Recordset
    
    If (loadedcheck) Then Exit Sub
    
    Set m_conn = New ADODB.Connection
    Set rs = New ADODB.Recordset
    
    m_conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};" & _
                "DBQ=" & strDBName & ";" & _
                "UID=" & strUser & ";" & _
                "PWD=" & strPassword & ";")
    
    Call rs.Open("SELECT * FROM myDB", m_conn)
    
    Call rs.MoveFirst
    
    index = 0
    
    Do
    
      If (index > 0) Then 
        Load CheckGDW(index) 
        CheckGDW(index).Top = CheckGDW(index).Height * index + CheckGDW(index).Top
      End If 
    
      CheckGDW(index).Visible = True 
      CheckGDW(index).Caption = rs!CustomerID
      
      index = index + 1
      Call rs.MoveNext
      
    Loop Until rs.EOF()
    
    loadedcheck = True
    -Shickadance

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    Doh, sorry I didn't get back to you about the Database stuff. I used ADO in my example, you are using DAO. But It looks like you have it figured out, excellent.
    -Shickadance

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    list view

    Yes i figured it out, one more thing

    the above code gives a column of check boxes to the amount in the database so i would like these check boxes inside a list view so i can scroll up and down through the selections incase the database is updated with new customers.

    Many thanks

  6. #6
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Hello again.

    This may be what you are after.

    Set the ListView.View Property to lvwReport.
    Set the ListView.CheckBoxes Property to True

    Code:
    Private Sub Form_Activate()
        Dim Index As Long
    
        If (loadedcheck) Then Exit Sub
    
        Do
          ListView1.ListItems.Add , rs!CustomerID, rs!CustomerID
          ListView1.ListItems.Item(rs!CustomerID).ListSubItems.Add , , rs!CustomerName
    
          Call rs.MoveNext
    
        Loop Until rs.EOF()
    
        loadedcheck = True
    
    End Sub
    Iain, thats with an i by the way!

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    property

    Where is this set?

    Set the ListView.View Property to lvwReport.
    Set the ListView.CheckBoxes Property to True

  8. #8
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    You can do it at design time in the properties window of the ListView.

    Or you could do it at run time in the form_load / activate event.
    Iain, thats with an i by the way!

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    listview

    I seem to be missing vital components for this, please be patient.

    If my list view window is
    List1

    List1.ListItems .. this should be apparent, BUT, i cannot extend to .ListItems only .List what is mssing?


  10. #10
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Sorry, i don't understand what you mean.

    Could you please explain what you are trying to do a bit better.
    Iain, thats with an i by the way!

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    update existing

    So this:
    i = 0
    rs.MoveFirst
    Do Until rs.EOF = True
    CheckGDW(i).Tag = rs!CustomerID
    i = i + 1
    rs.MoveNext
    Loop


    ...would be?

    Many thanks

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    and this

    What is the alternative to LBound with list view

    code:
    Dim i As Integer
    If Check2.Value = 1 Then
    For i = CheckGDW.LBound To CheckGDW.Ubound
    CheckGDW(i).Value = vbChecked
    Next i
    ElseIf Check2.Value = 0 Then
    For i = CheckGDW.LBound To CheckGDW.Ubound
    CheckGDW(i).Value = 0
    Next i
    End If

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    listview

    With reference to the above, what i mean is i want exactly what i had with the check boxes so i can select certain customers but they are in a list view so its scrollable..

    i have managed to get a list with check boxes but they dont work becuase i have CheckGDW instead, i would just like to no what is similar to .tag for selecting and .lBound and .Ubound

    Many thanks..

    Gary

  14. #14
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    God damn refresh of this forum now. half way through posting, and it refreshes itself and i lose all of my typing i'm really pissed off now.

    Any way

    First Post
    I have set the key of each item in the ListView to the Customer ID so this should not be a problem


    Second Post
    Code:
    Dim myListItem As ListItem
    
    If Check2.Value = 1 Then 
      For Each myListItem In ListView1.ListItems
        myListItem.Checked = True
      Next
    Else
      For Each myListItem In ListView1.ListItems
        myListItem.Checked = False
      Next
    End If

    Third Post
    To check which customers are selected

    Code:
      For Each myListItem In ListView1.ListItems
        If myListItem.Checked = True Then
          'the customer has been selected
     
          'returns the customers ID
          msgbox myListItem.Key
        End If
      Next
    Iain, thats with an i by the way!

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    to avoid buggin you

    To avoid bugging you with confusion i have listed the code below because i get a Method or Data not defined using

    ListView.ListItems

    code:
    -----------------------------------------------------------
    Private Sub getCustId()
    Dim i
    Dim rs As Recordset
    'set db location
    Set DB = OpenDatabase(App.Path & "\configuration.mdb")
    'Open the Contact table
    Set rs = DB.OpenRecordset("SELECT netVESPAWeb.*, ISDefine.SetPreProccessor, altCarriers.Carrier FROM (ISDefine INNER JOIN netVESPAWeb ON ISDefine.ID = netVESPAWeb.ISPreProccessorType) INNER JOIN altCarriers ON netVESPAWeb.SetCarriers = altCarriers.ID", dbOpenDynaset)

    i = 0
    rs.MoveFirst
    Do Until rs.EOF = True
    CheckGDW(i).Tag = rs!CustomerID
    i = i + 1
    rs.MoveNext
    Loop
    End Su

    'this is in another area..
    For i = CheckGDW.LBound To CheckGDW.Ubound
    If CheckGDW(i).Value = vbChecked Then
    If findCust(CheckGDW(i).Tag) = True Then
    ReadMDBTable
    MakeApp
    Else
    MsgBox "The Customer was not found!"
    End If
    End If
    Next i

    'select all and clear all
    Private Sub Check2_Click()
    Dim i As Integer
    If Check2.Value = 1 Then
    For i = CheckGDW.LBound To CheckGDW.Ubound
    CheckGDW(i).Value = vbChecked
    Next i
    ElseIf Check2.Value = 0 Then
    For i = CheckGDW.LBound To CheckGDW.Ubound
    CheckGDW(i).Value = 0
    Next i
    End If
    End Sub

    Many thanks

  16. #16
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    This should sort you out then.

    I am assuming you are moving away from the array of Checkboxes to the list view.

    Code:
    Private Sub getCustId()
        Dim i
        Dim rs As Recordset
        'set db location
        Set DB = OpenDatabase(App.Path & "\configuration.mdb")
        'Open the Contact table
        Set rs = DB.OpenRecordset("SELECT netVESPAWeb.*, ISDefine.SetPreProccessor, altCarriers.Carrier FROM (ISDefine INNER JOIN netVESPAWeb ON ISDefine.ID = netVESPAWeb.ISPreProccessorType) INNER JOIN altCarriers ON netVESPAWeb.SetCarriers = altCarriers.ID", dbOpenDynaset)
    
    
        rs.MoveFirst
        Do Until rs.EOF = True
          ListView1.ListItems.Add , rs!CustomerID, rs!CustomerID
          rs.MoveNext
        Loop
        
    End Sub
    
    
    
    'this is in another area..
    Dim myListItem As ListItem
    
    For Each myListItem In ListView1.ListItems
      If myListItem.Checked = True Then
        If findCust(myListItem.Key) = True Then
          ReadMDBTable
          MakeApp
        Else
          MsgBox "The Customer was not found!"
        End If
      End If
    Next
    
    
    'select all and clear all
    Private Sub Check2_Click()
        Dim myListItem As ListItem
    
        If Check2.Value = 1 Then
          For Each myListItem In ListView1.ListItems
            myListItem.Checked = True
          Next i
        ElseIf Check2.Value = 0 Then
          For Each myListItem In ListView1.ListItems
            myListItem.Checked = False
          Next i
        End If
        
    End Sub
    Iain, thats with an i by the way!

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446
    Dim myListItem As ListItem

    Yet use this ListView.ListItems

    plus it does'nt work for me. undefined, where is this declared??

    Many thanks

  18. #18
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Are you using a ListView or a ListBox?

    The only possible reason i can see that you are having this problem is becuse you are using a ListBox. If you are you should have said. In your question you specified ListView.

    If you want the listview, add the "Microsoft Windows Common Controls 6.0" control from the Project -> Components list.
    Iain, thats with an i by the way!

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    LISTBOX

    LISTBOX, but i'll change to listview, where is it??

  20. #20
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Goto the Project Menu.
    Select Components
    Check the "Microsoft Windows Common Controls 6.0" box.
    Click OK.

    The ListView should be on the ToolBar.
    Iain, thats with an i by the way!

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446
    no i'll not!!

  22. #22
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Don't then. See if i care
    Iain, thats with an i by the way!

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    LISTBOX

    What your saying is all the above is invalid?

    Oh dear... i must clarify in future, boxes views, bloody hell.

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    help

    HELP...!

  25. #25
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    This should work for a ListBox

    Code:
    Private Sub getCustId()
        Dim i
        Dim rs As Recordset
        'set db location
        Set DB = OpenDatabase(App.Path & "\configuration.mdb")
        'Open the Contact table
        Set rs = DB.OpenRecordset("SELECT netVESPAWeb.*, ISDefine.SetPreProccessor, altCarriers.Carrier FROM (ISDefine INNER JOIN netVESPAWeb ON ISDefine.ID = netVESPAWeb.ISPreProccessorType) INNER JOIN altCarriers ON netVESPAWeb.SetCarriers = altCarriers.ID", dbOpenDynaset)
    
    
        rs.MoveFirst
        Do Until rs.EOF = True
          List1.AddItem rs!CustomerID
          rs.MoveNext
        Loop
        
    End Sub
    
    
    
    'this is in another area..
    Dim i As Integer
    
    For i = 0 To List1.ListCount - 1
      If List1.Selected(i) = True Then
        If findCust(List1.List(i)) = True Then
          ReadMDBTable
          MakeApp
        Else
          MsgBox "The Customer was not found!"
        End If
      End If
    Next
    
    
    'select all and clear all
    Private Sub Check2_Click()
        Dim i As Integer
    
        If Check2.Value = 1 Then
          For i = 0 To List1.ListCount - 1
            List1.Selected(i) = True
          Next i
        ElseIf Check2.Value = 0 Then
          For i = 0 To List1.ListCount - 1
            List1.Selected(i) = False
          Next i
        End If
        
    End Sub
    Iain, thats with an i by the way!

  26. #26
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    this is the same question as in LISTVIEW..
    one should be deleted..it's confusing when different people
    are answere the same question in differen areas of the Q & A
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    ureeka ka ka!!

    ureeka ka ka!! nice one Iain17,.. (strange name)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width