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 -
Private Sub Form_Load()
-
ListView1.View = lvwReport
-
ListView1.ColumnHeaders.Add , , "NAME"
-
ListView1.ColumnHeaders.Add , , "ID"
-
ListView1.Refresh
-
rs.Open "select * from empdetail", conn, adOpenStatic, adLockOptimistic
-
While Not rs.EOF
-
ListView1.Refresh
-
With ListView1
-
Set lvitem = ListView1.ListItems.Add(, , rs!Name)
-
lvitem.SubItems(1) = rs!id
-
End With
-
rs.MoveNext
-
Wend
-
rs.Close
-
Set rs = Nothing
-
LVFullRowSelect ListView1
-
Form2.txtgros.Enabled = False
-
Form2.txtnsal.Enabled = False
-
Form2.txtoh.Enabled = False
-
Form2.txtotamt.Enabled = False
-
Form2.txtotrt.Enabled = False
-
Form2.txtrate.Enabled = False
-
Form2.txttr.Enabled = False
-
dtpay.Value = Date
-
End Sub
The following is in first form,adding new record to the database -
Private Sub cmdAdd_Click()
-
txtid.Enabled = True
-
If Form1.txtid.Text = " " Then
-
MsgBox "Enter the id,Please!!!", vbOKOnly, "PAYROLL"
-
txtid.SetFocus
-
With txtid
-
.SelStart = 0
-
'.SelLength = Len(txtid.Text)
-
.SetFocus
-
End With
-
Exit Sub
-
ElseIf txtname.Text = " " Then
-
MsgBox "Enter the name,Please!!!", vbOKOnly, "PAYROLL"
-
'txtname.SetFocus
-
Exit Sub
-
With txtname
-
.SelStart = 0
-
'.SelLength = Len(txtname.Text)
-
.SetFocus
-
End With
-
'End If
-
ElseIf txtwhr.Text = " " Then
-
MsgBox "Enter the working hours,Please!!!", vbOKOnly, "PAYROLL"
-
'txtwhr.SetFocus
-
Exit Sub
-
With txtwhr
-
.SelStart = 0
-
'.SelLength = Len(txtwhr.Text)
-
.SetFocus
-
End With
-
'End If
-
ElseIf txtrate.Text = " " Then
-
MsgBox "Enter the rate,Please!!!", vbOKOnly, "PAYROLL"
-
txtrate.SetFocus
-
Exit Sub
-
With txtrate
-
.SelStart = 0
-
'.SelLength = Len(txtrate.Text)
-
.SetFocus
-
End With
-
''End If
-
ElseIf txtorate.Text = " " Then
-
MsgBox "Enter the Overtime Rate,Please!!!", vbOKOnly, "PAYROLL"
-
'txtorate.SetFocus
-
'txtname.SetFocus
-
Exit Sub
-
With txtorate
-
.SelStart = 0
-
'.SelLength = Len(txtname.Text)
-
.SetFocus
-
End With
-
'End If
-
'End If
-
Else
-
rs.Open "select * from empdetail Where ID='" & txtid.Text & "'", conn, adOpenStatic, adLockOptimistic
-
If rs.EOF Then
-
conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
-
MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
-
Else
-
'ID Found In DB (Duplicate)
-
MsgBox "Duplicate Entry"
-
End If
-
'End If
-
rs.Close
-
Set rs = Nothing
-
ListView1.ListItems.Clear
-
addcol
-
Form1.txtid.Text = " "
-
Form1.txtname.Text = " "
-
Form1.txtwhr.Text = " "
-
Form1.txtrate.Text = " "
-
Form1.txtorate.Text = " "
-
End If
-
End Sub
Please check the code!!!
1 1167
Please find a related article here .
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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.
-----------------------...
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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...
| |