|
-
Jul 3rd, 2000, 10:50 AM
#1
Thread Starter
Hyperactive Member
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
-
Jul 3rd, 2000, 12:01 PM
#2
_______
??
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
-
Jul 3rd, 2000, 12:06 PM
#3
Hyperactive Member
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
-
Jul 4th, 2000, 04:47 PM
#4
Hyperactive Member
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.
-
Jul 5th, 2000, 03:49 AM
#5
Thread Starter
Hyperactive Member
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
-
Jul 5th, 2000, 04:01 AM
#6
Fanatic Member
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!
-
Jul 5th, 2000, 04:41 AM
#7
Thread Starter
Hyperactive Member
property
Where is this set?
Set the ListView.View Property to lvwReport.
Set the ListView.CheckBoxes Property to True
-
Jul 5th, 2000, 04:43 AM
#8
Fanatic Member
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!
-
Jul 5th, 2000, 05:10 AM
#9
Thread Starter
Hyperactive Member
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?
-
Jul 5th, 2000, 05:21 AM
#10
Fanatic Member
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!
-
Jul 5th, 2000, 05:28 AM
#11
Thread Starter
Hyperactive Member
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
-
Jul 5th, 2000, 05:34 AM
#12
Thread Starter
Hyperactive Member
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
-
Jul 5th, 2000, 05:37 AM
#13
Thread Starter
Hyperactive Member
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
-
Jul 5th, 2000, 05:46 AM
#14
Fanatic Member
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!
-
Jul 5th, 2000, 06:24 AM
#15
Thread Starter
Hyperactive Member
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
-
Jul 5th, 2000, 06:52 AM
#16
Fanatic Member
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!
-
Jul 5th, 2000, 07:06 AM
#17
Thread Starter
Hyperactive Member
Dim myListItem As ListItem
Yet use this ListView.ListItems
plus it does'nt work for me. undefined, where is this declared??
Many thanks
-
Jul 5th, 2000, 07:11 AM
#18
Fanatic Member
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!
-
Jul 5th, 2000, 07:28 AM
#19
Thread Starter
Hyperactive Member
LISTBOX
LISTBOX, but i'll change to listview, where is it??
-
Jul 5th, 2000, 07:31 AM
#20
Fanatic Member
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!
-
Jul 5th, 2000, 07:33 AM
#21
Thread Starter
Hyperactive Member
-
Jul 5th, 2000, 07:35 AM
#22
Fanatic Member
Don't then. See if i care
Iain, thats with an i by the way!
-
Jul 5th, 2000, 07:38 AM
#23
Thread Starter
Hyperactive Member
LISTBOX
What your saying is all the above is invalid?
Oh dear... i must clarify in future, boxes views, bloody hell.
-
Jul 5th, 2000, 08:07 AM
#24
Thread Starter
Hyperactive Member
-
Jul 5th, 2000, 08:27 AM
#25
Fanatic Member
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!
-
Jul 5th, 2000, 08:29 AM
#26
_______
<?>
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
-
Jul 5th, 2000, 09:47 AM
#27
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|