473,657 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List View Control Columns From 2 Tables???

103 New Member
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 2217
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Open Recordset like this :

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

REgards
Veena
Jan 11 '08 #2
Vbbeginner07
103 New Member
Hi,
Open Recordset like this :
rs.Open "select distinct S.id , e.* from saldetail S, EmpMas E Where S.ID = E.ID ", conn, adOpenStatic, adLockOptimisti c
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 New Member
Hi,
Open Recordset like this :
rs.Open "select distinct S.id , e.* from saldetail S, EmpMas E Where S.ID = E.ID ", conn, adOpenStatic, adLockOptimisti c
REgards
Veena
rs1.Open "select empdetail.id,sa ldetail.name where empdetail.id = saldetail.id", conn, adOpenStatic, adLockOptimisti c

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

try this :


rs1.Open "select empdetail.id,sa ldetail.name from empdetail , saldetail where empdetail.id = saldetail.id", conn, adOpenStatic, adLockOptimisti c

Regards
Veena
Jan 14 '08 #5
Vbbeginner07
103 New Member
Hi,
try this :
dim ivitem as Listitem
rs1.Open "select empdetail.id,sa ldetail.name from empdetail , saldetail where empdetail.id = saldetail.id", conn, adOpenStatic, adLockOptimisti c
Regards
Veena
rs.Open "select distinct id from saldetail", conn, adOpenStatic, adLockOptimisti c
rs1.Open "select empdetail.name, saldetail.id from empdetail,salde tail where saldetail.id = empdetail.id", conn, adOpenStatic, adLockOptimisti c
ListView1.Refre sh
While Not rs.EOF
While Not rs1.EOF
With ListView1
Set lvitem = ListView1.ListI tems.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.Refre sh
ListView2.Refre sh


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 Recognized Expert Top Contributor
Hi,

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

Regards
Veena
Jan 14 '08 #7
Vbbeginner07
103 New Member
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 New Member
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 New Member
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

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

Similar topics

8
4322
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. Basically I want to say: If fk_ID is in list then do these statements to that record
5
2471
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 On Open event and have a the default 10% and give the user the option to change it to 0% I have referenced th appropriate library and the default value of the field to change is 0.1
10
2522
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 for ASP.NET however most of them are already compiled and don't come with source code. I am really just looking for an example on how to create my own Tree Control. Thanks a bunch.
2
332
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 between the selected grid and the next grid. however i cannot seem to find a method of obtaing the position coordinate for that area.? and ideas on how to go about finding the position? WStoreyII
0
3232
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 way... here is my code on how I did it to help anyone starting out get an idea of how to use virtual mode in ..NET 2.0 Imports CrystalDecisions.CrystalReports.Engine Imports CrystalDecisions.Shared
9
12906
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... willing to spend money for a control.. thanks a lot!
4
64588
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 determines the available options in the other. TERMINOLOGY Row Source: The table/query from which the Combo Box or List Box gets its values. Note: There are other types of row sources that can be used but for simplicity we will stick with Tables...
2
2482
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 allows me to add columns. I typed in the following dim colHeader as ListBox.Col (And no column appears). With DevExpress I am able to add columns definng my own columens, and back a while ago, I know I was able to use the Microsoft List Box...
0
8392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1611
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.