473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

List View Control Columns From 2 Tables???

103 100+
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ListView1.Refresh
  3. ListView2.Refresh
  4. ListView1.View = lvwReport
  5. ListView2.View = lvwReport
  6. ListView1.ColumnHeaders.Add , , "ID"
  7. 'ListView1.ColumnHeaders.Add , , "NAME"
  8. ListView2.ColumnHeaders.Add , , "DATE"
  9. ListView2.Refresh
  10. rs.Open "select distinct id  from saldetail", conn, adOpenStatic, adLockOptimistic
  11. ListView1.Refresh
  12. While Not rs.EOF
  13.  
  14. With ListView1
  15. Set lvitem = ListView1.ListItems.Add(, , rs!id)
  16. 'rs1.Open "select * from empdetail where id = '" & ListView1.ListItemsItem & "'", conn, adOpenStatic, adLockOptimistic
  17. 'lvitem.SubItems(1) = rs1!Name
  18. End With
  19. rs.MoveNext
  20. Wend
  21. rs.Close
  22. Set rs = Nothing
  23. ListView1.Refresh
  24. ListView2.Refresh
  25. end sub
  26.  
the above code is to retrieve id from a table saldetail,where i have to retrieve the corresponding names of the ids from another table,is it possible in alist view control???
where i have gone wrong???
please help
Jan 11 '08 #1
15 2205
QVeen72
1,445 Expert 1GB
Hi,

Open Recordset like this :

rs.Open "select distinct S.id , e.* from saldetail S, EmpMas E Where S.ID = E.ID ", conn, adOpenStatic, adLockOptimistic

REgards
Veena
Jan 11 '08 #2
Vbbeginner07
103 100+
Hi,
Open Recordset like this :
rs.Open "select distinct S.id , e.* from saldetail S, EmpMas E Where S.ID = E.ID ", conn, adOpenStatic, adLockOptimistic
REgards
Veena
But Veena,
I cant understand that,can u please explain it once more,
even im getting errors in EmpMass
Please explain it
Jan 11 '08 #3
Vbbeginner07
103 100+
Hi,
Open Recordset like this :
rs.Open "select distinct S.id , e.* from saldetail S, EmpMas E Where S.ID = E.ID ", conn, adOpenStatic, adLockOptimistic
REgards
Veena
rs1.Open "select empdetail.id,saldetail.name where empdetail.id = saldetail.id", conn, adOpenStatic, adLockOptimistic

'i have tried with this code too tat too error occurs
Jan 14 '08 #4
QVeen72
1,445 Expert 1GB
Hi,

try this :


rs1.Open "select empdetail.id,saldetail.name from empdetail , saldetail where empdetail.id = saldetail.id", conn, adOpenStatic, adLockOptimistic

Regards
Veena
Jan 14 '08 #5
Vbbeginner07
103 100+
Hi,
try this :
dim ivitem as Listitem
rs1.Open "select empdetail.id,saldetail.name from empdetail , saldetail where empdetail.id = saldetail.id", conn, adOpenStatic, adLockOptimistic
Regards
Veena
rs.Open "select distinct id from saldetail", conn, adOpenStatic, adLockOptimistic
rs1.Open "select empdetail.name,saldetail.id from empdetail,saldetail where saldetail.id = empdetail.id", conn, adOpenStatic, adLockOptimistic
ListView1.Refresh
While Not rs.EOF
While Not rs1.EOF
With ListView1
Set lvitem = ListView1.ListItems.Add(, , rs!id)
lvitem.SubItems(1) = rs1!Name
End With
rs.MoveNext
rs1.MoveNext
Wend
Wend
rs1.Close
Set rs1 = Nothing
rs.Close
Set rs = Nothing
ListView1.Refresh
ListView2.Refresh


this codeis to add two coulmns to a listview where both are from different tables.
But the line
lvitem.subitems(1)=rs1!Nameis not working
Jan 14 '08 #6
QVeen72
1,445 Expert 1GB
Hi,

Before adding sub-items, you have to add Column Headers to the listview..

Regards
Veena
Jan 14 '08 #7
Vbbeginner07
103 100+
Hi,
Before adding sub-items, you have to add Column Headers to the listview..
its added at first
but error showing invariable optional
Nick
Jan 14 '08 #8
pureenhanoi
175 100+
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. 'ListView1.Refresh    ' the list view is blank on start-up, does not need any refresh
  3. 'ListView2.Refresh  ' donot refresh
  4. ListView1.View = lvwReport
  5. ListView2.View = lvwReport
  6. ListView1.ColumnHeaders.Add , , "ID"
  7. ListView1.ColumnHeaders.Add , , "NAME"
  8. ListView2.ColumnHeaders.Add , , "DATE"
  9. 'ListView2.Refresh 'again
  10. rs.Open "select distinct id  from saldetail", conn, adOpenStatic, adLockOptimistic
  11. 'ListView1.Refresh   'and again
  12. While Not rs.EOF
  13.  
  14. 'With ListView1      'donot need "With", 
  15. Set lvitem = ListView1.ListItems.Add(, , rs!id)
  16. 'this code seem good, except ListView1.ListItemsItem ??? what does it mean
  17. 'rs1.Open "select * from empdetail where id = '" & ListView1.ListItemsItem & "'", conn, adOpenStatic, adLockOptimistic
  18. 'Try this
  19. rs1.Open "select * from empdetail where id = '" & rs!id & "'", conn, adOpenStatic, adLockOptimistic
  20. lvitem.SubItems(1) = rs1!Name
  21. 'End With
  22. rs.MoveNext
  23. Wend
  24. rs.Close
  25. Set rs = Nothing
  26. 'ListView1.Refresh
  27. 'ListView2.Refresh
  28. end sub
  29.  
the above code is to retrieve id from a table saldetail,where i have to retrieve the corresponding names of the ids from another table,is it possible in alist view control???
where i have gone wrong???
please help
Your actual code can do things you need, except it has lot of extra statement
Jan 15 '08 #9
Vbbeginner07
103 100+
Your actual code can do things you need, except it has lot of extra statement
but that doesnt work,now i have used the code
Expand|Select|Wrap|Line Numbers
  1.  
  2. ListView2.Refresh
  3. rs1.Open "select empdetail.name,saldetail.id from empdetail,saldetail where saldetail.id = empdetail.id", conn, adOpenStatic, adLockOptimistic
  4. While Not rs1.EOF
  5. With ListView1
  6. vitem.SubItems(1) = rs1!Name
  7. End With
  8. rs1.MoveNext
  9. Wend
  10. rs1.Close
  11. Set rs1 = Nothing
  12.  
that adds only one record,ie the last record,please help...........
Jan 17 '08 #10
pureenhanoi
175 100+
but that doesnt work,now i have used the code
Expand|Select|Wrap|Line Numbers
  1.  
  2. ListView2.Refresh
  3. rs1.Open "select empdetail.name,saldetail.id from empdetail,saldetail where saldetail.id = empdetail.id", conn, adOpenStatic, adLockOptimistic
  4. While Not rs1.EOF
  5. With ListView1
  6. vitem.SubItems(1) = rs1!Name
  7. End With
  8. rs1.MoveNext
  9. Wend
  10. rs1.Close
  11. Set rs1 = Nothing
  12.  
that adds only one record,ie the last record,please help...........
No no, not that SQL state ment. See my reply above. you can copy that code and paste into your program. After that, you can delete all comment line. Try that code.
One more else, the saldetail table, as i think it has more than one field (ID), so, why do you SELECT only ID on salDetail
Jan 17 '08 #11
QVeen72
1,445 Expert 1GB
Hi,

Try this :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ListView1.Refresh
  3. ListView2.Refresh
  4. ListView1.View = lvwReport
  5. ListView2.View = lvwReport
  6. ListView1.ColumnHeaders.Add , , "ID"
  7. ListView1.ColumnHeaders.Add , , "NAME"
  8. ListView2.ColumnHeaders.Add , , "DATE"
  9. ListView2.Refresh
  10. rs.Open "select empdetail.name,saldetail.id from empdetail,saldetail where saldetail.id = empdetail.id", conn, adOpenStatic, adLockOptimistic
  11. If Not rs.EOF Then
  12.     rs.MoveFirst
  13.     Do While Not rs.EOF
  14.          With ListView1
  15.          Set lvitem = ListView1.ListItems.Add(, , rs!id)
  16.          lvitem.SubItems(1) = rs!Name
  17.          rs.MoveNext
  18.      Loop
  19. End If
  20. rs.Close
  21. Set rs = Nothing
  22. ListView1.Refresh
  23. ListView2.Refresh
  24. end sub
  25.  
  26.  
Regards
Veena
Jan 17 '08 #12
Vbbeginner07
103 100+
Hi,

Try this :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ListView1.Refresh
  3. ListView2.Refresh
  4. ListView1.View = lvwReport
  5. ListView2.View = lvwReport
  6. ListView1.ColumnHeaders.Add , , "ID"
  7. ListView1.ColumnHeaders.Add , , "NAME"
  8. ListView2.ColumnHeaders.Add , , "DATE"
  9. ListView2.Refresh
  10. rs.Open "select empdetail.name,saldetail.id from empdetail,saldetail where saldetail.id = empdetail.id", conn, adOpenStatic, adLockOptimistic
  11. If Not rs.EOF Then
  12.     rs.MoveFirst
  13.     Do While Not rs.EOF
  14.          With ListView1
  15.          Set lvitem = ListView1.ListItems.Add(, , rs!id)
  16.          lvitem.SubItems(1) = rs!Name
  17.          rs.MoveNext
  18.      Loop
  19. End If
  20. rs.Close
  21. Set rs = Nothing
  22. ListView1.Refresh
  23. ListView2.Refresh
  24. end sub
  25.  
  26.  
Regards
Veena

do loop has a pblm???
Jan 17 '08 #13
QVeen72
1,445 Expert 1GB
Hi,

Tried the Code...?
Copy the entire code and run..
What error you are getting...?

Regards
Veena
Jan 17 '08 #14
Vbbeginner07
103 100+
Hi,
Tried the Code...?
Copy the entire code and run..
What error you are getting...?
Regards
Veena
yes,
Loop without do
i tried with while that too wend wthout while........

Nick
Jan 17 '08 #15
Vbbeginner07
103 100+
Hi,
Tried the Code...?
Copy the entire code and run..
What error you are getting...?
Regards
Veena
Yes ,
a slight pblm occured due to end withnow its working
THANKS VEENA.....................
Jan 17 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
5
by: David Deacon | last post by:
Hi i was given the following advise,below my OriginalQuestion I am a little new to ADOX can you direct me to the following Do i place the code behind a button on a form? Or do i place it in the...
10
by: dwok | last post by:
Does anyone know of a good article that discusses creating a "Tree View" control in ASP.NET? Or perhaps a Tree View Control that comes with source code? I have come across a lot of tree controls...
2
by: WStoreyII | last post by:
I wish to make a custom view of relations in a datagrid what i want to do is when the plus sign is clicked instead of showing the link label i want to show a grid with the subtable in that area...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
9
by: Smokey Grindle | last post by:
does anyone know of any good tree list view controls (for commercial usage)? I need something that is high quality, and looks similar to the detail view of the list view and in a tree format......
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
2
by: Greg | last post by:
I have a listbox control that displays it's data using the DataSource, DisplayMember and ValueMember properties. I've worked a thrid party control (DevExpress) that a similar ListBox control that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.