473,324 Members | 2,124 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,324 software developers and data experts.

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

103 100+
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 1167
debasisdas
8,127 Expert 4TB
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
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...
4
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. -----------------------...
8
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...
8
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...
1
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. ...
4
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...
3
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...
1
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...
16
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.