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 1179
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 '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...
|
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...
|
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...
|
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.
|
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...
| |
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...
|
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:
|
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...
|
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
|
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
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |