473,698 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The code displays only the first record.but???

103 New Member
The follwing code is of a listview where i have to a to display the id and the name from a particular table ,empdetail.

This is in the second form,dispalying id and name
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ListView1.View = lvwReport
  3. ListView1.ColumnHeaders.Add , , "NAME"
  4. ListView1.ColumnHeaders.Add , , "ID"
  5. ListView1.Refresh
  6. rs.Open "select * from empdetail", conn, adOpenStatic, adLockOptimistic
  7. While Not rs.EOF
  8. ListView1.Refresh
  9. With ListView1
  10. Set lvitem = ListView1.ListItems.Add(, , rs!Name)
  11. lvitem.SubItems(1) = rs!id
  12. End With
  13. rs.MoveNext
  14. Wend
  15. rs.Close
  16. Set rs = Nothing
  17. LVFullRowSelect ListView1
  18. Form2.txtgros.Enabled = False
  19. Form2.txtnsal.Enabled = False
  20. Form2.txtoh.Enabled = False
  21. Form2.txtotamt.Enabled = False
  22. Form2.txtotrt.Enabled = False
  23. Form2.txtrate.Enabled = False
  24. Form2.txttr.Enabled = False
  25. dtpay.Value = Date
  26. End Sub
The following is in first form,adding new record to the database
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. txtid.Enabled = True
  3. If Form1.txtid.Text = " " Then
  4. MsgBox "Enter the id,Please!!!", vbOKOnly, "PAYROLL"
  5. txtid.SetFocus
  6. With txtid
  7. .SelStart = 0
  8. '.SelLength = Len(txtid.Text)
  9. .SetFocus
  10. End With
  11. Exit Sub
  12. ElseIf txtname.Text = " " Then
  13. MsgBox "Enter the name,Please!!!", vbOKOnly, "PAYROLL"
  14. 'txtname.SetFocus
  15. Exit Sub
  16. With txtname
  17. .SelStart = 0
  18. '.SelLength = Len(txtname.Text)
  19. .SetFocus
  20. End With
  21. 'End If
  22. ElseIf txtwhr.Text = " " Then
  23. MsgBox "Enter the working hours,Please!!!", vbOKOnly, "PAYROLL"
  24. 'txtwhr.SetFocus
  25. Exit Sub
  26. With txtwhr
  27. .SelStart = 0
  28. '.SelLength = Len(txtwhr.Text)
  29. .SetFocus
  30. End With
  31. 'End If
  32. ElseIf txtrate.Text = " " Then
  33. MsgBox "Enter the rate,Please!!!", vbOKOnly, "PAYROLL"
  34. txtrate.SetFocus
  35. Exit Sub
  36. With txtrate
  37. .SelStart = 0
  38. '.SelLength = Len(txtrate.Text)
  39. .SetFocus
  40. End With
  41. ''End If
  42. ElseIf txtorate.Text = " " Then
  43. MsgBox "Enter the Overtime Rate,Please!!!", vbOKOnly, "PAYROLL"
  44. 'txtorate.SetFocus
  45. 'txtname.SetFocus
  46. Exit Sub
  47. With txtorate
  48. .SelStart = 0
  49. '.SelLength = Len(txtname.Text)
  50. .SetFocus
  51. End With
  52. 'End If
  53. 'End If
  54. Else
  55. rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimistic
  56. If rs.EOF Then
  57. conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
  58. MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
  59. Else
  60. 'ID Found In DB (Duplicate)
  61. MsgBox "Duplicate Entry"
  62. End If
  63. 'End If
  64. rs.Close
  65. Set rs = Nothing
  66. ListView1.ListItems.Clear
  67. addcol
  68. Form1.txtid.Text = " "
  69. Form1.txtname.Text = " "
  70. Form1.txtwhr.Text = " "
  71. Form1.txtrate.Text = " "
  72. Form1.txtorate.Text = " "
  73. End If
  74. End Sub
Please check the code!!!
Feb 6 '08 #1
1 1179
debasisdas
8,127 Recognized Expert Expert
Please find a related article here .
Feb 6 '08 #2

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

Similar topics

6
2220
by: Kingdom | last post by:
I'm using this script to dynamicaly populate 2 dropdowns and dispaly the results. Choose a component type from the first drop down, lets say 'car' and the second box will list all the car 'manufacturers' and the display will then provide all the rest of the info from the other fields. I need to eliminate all the duplicates in the First Drop Down as it currently displays an entry for every record, many are identical, I might have over...
4
1931
by: dixie | last post by:
I have come across some code to walk through the records of a corrupt table and copy it record by record to a new table. It comes from the MVPS.Org site and is as follows. ----------------------- (Q) How can I recover records from a corrupt table? (A) First, using Access while in the database window, copy the table's structure only from the corrupt table, if possible. Then using the code below, copy each individual row from the old...
8
5491
by: jquest | last post by:
Hi Again; I have had help from this group before and want to thank everyone, especially PCDatasheet. My database includes a field called HomePhone, it uses the (xxx)xxx-xxx format to include area code. When a customer calls, I currently use Ctrl F with the HomePhone field highlighted. Then I enter the last 4 digits and use the find next option. This is cumbersome, so I have tried several methods (including a macro) using comand...
8
3215
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled 'search' may be clicked on by the user and the user can then search all records by postcode. I want to do this to prevent duplicate data entry.
1
1299
by: Thelma Lubkin | last post by:
I have a form that displays and allows user to edit colorsets, each colorset containing between 3and 11 colors. Each individual color is a combination of numerical values of Red,Blue, and Green. The user can browse the colorsets by going from record to record in the form. A subform displays the actual colors in the selected set. The subform's recordset has fields for colorsetname , sequenceNumber, Redvalue,BlueValue and GreenValue, and...
4
2249
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms application that is going to be used to extract data from a legacy system (VSAM based mainframe file structure), and output data in pipe-delimited record layouts, multiple record types per file, one file per chosen client. I have been working on...
3
2165
by: Danny Tuppeny | last post by:
Hi all, Is there a way in something like a DataList, to have a different colour background (via CssClass) without repeating all my code in both the ItemTemplate and AlternatingItemTemplate blocks? I have quite a lot of stuff in the ItemTemplate block, but because so much of it is bound fields, creating a seperate user control mapping all of these fields across would be a nightmare to maintain. Instead, I'd like something like:
1
2509
by: Peter Herath | last post by:
I have created a report using sample codes taken by the forum. one problem is that the report displays the field/column names in the table in columnar format(field names display in rows.) but i want to be able to display filed names and its relevant data in tabular format in the repor but the code itself just displays only the fields in rows and another problem is that, to set the record source. the way i set the record source property of the...
16
3551
by: google | last post by:
In a continuous form the following code is under a button in the form header. In Access 2003 and earlier, this goes to a new record, then adds relevant data to that new record. DoCmd.GoToRecord , , A_NEWREC If <some codeThen = "CA002" Else
0
755
by: ags5406 | last post by:
Hi - I'm very new (as in the last couple hours) to using VB.NET (2005) with SQL DB files (.mdf). Here's what I've done... I've got a .MDF file with several tables in it. So from the dev env... File-->New Project (windows application)... Then in the server explorer add connection to my SQL server DB file. So it's got five tables and a single database diagram that shows all
0
8674
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
8603
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
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9023
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
8861
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...
0
5860
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
4366
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
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
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.