-
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
-
??
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.
-
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
-
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.
-
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
-
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
-
property
Where is this set?
Set the ListView.View Property to lvwReport.
Set the ListView.CheckBoxes Property to True
-
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.
-
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?
-
Sorry, i don't understand what you mean.
Could you please explain what you are trying to do a bit better.
-
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
-
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
-
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
-
God damn refresh of this forum now. half way through posting, and it refreshes itself and i lose all of my typing :mad: 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
-
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
-
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
-
Dim myListItem As ListItem
Yet use this ListView.ListItems
plus it does'nt work for me. undefined, where is this declared??
Many thanks
-
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.
-
LISTBOX
LISTBOX, but i'll change to listview, where is it??
-
Goto the Project Menu.
Select Components
Check the "Microsoft Windows Common Controls 6.0" box.
Click OK.
The ListView should be on the ToolBar.
-
-
Don't then. See if i care ;)
-
LISTBOX
What your saying is all the above is invalid?
Oh dear... i must clarify in future, boxes views, bloody hell.
-
help
-
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
-
<?>
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
-
ureeka ka ka!!
ureeka ka ka!! nice one Iain17,.. (strange name)