need help with entering listview control data into database.

J

jkendrick75

I am able to transfer data from text boxes to a listview control without
anyproblem. The problem comes in when trying to enter that data into a
database table.

my database table name is tblDefectCount.
my listview control is lsvListView.
i was told to try to use ADO to make the database connection for the form.
my code is below.
------------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
'Assumes the linked table is in the current database
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDefectCount", dbOpenDynaset)
Set Me.Recordset = rs
DoCmd.Maximize
End Su
-----------------------------------------------------------------------------------
'Add items from listview to table tblDefectCount
For intCounter2 = 1 To intCount
'rs.MoveLast
'rs.Open (tblDefectcount,cn,adOpenDynamic,adLockOptimistic, -1)
'rs.Fields("date").Value = Date
'rs.("Date") = Date
With rs
.Fields("Shift").Value = shift
db.Recordset.Fields("ID").Value = ID
db.Recordset.Fields("PressNumber").Value = lsvListView.ListItems. _
Item(intCounter2)
db.Recordset.Fields("MoldNumber").Value = lsvListView.ListItems. _
Item(intCounter2).SubItems(2)
db.Recordset.Fields("PartNumber").Value = lsvListView.ListItems. _
Item(intCounter2).SubItems(3)
db.Recordset.Fields("Operator").Value = lsvListView.ListItems. _
Item(intCounter2).SubItems(4)
db.Recordset.Fields("CycleTime").Value = lsvListView.ListItems. _
Item(intCounter2).SubItems(5)
db.Recordset.Fields("ActualCavities").Value = lsvListView.ListItems. _
Item(intCounter2).SubItems(6)
db.Recordset.Fields("ActualOps").Value = lsvListView.ListItems. _
Item(intCounter2).SubItems(7)
End With
db.Close
-------------------------------------------
This is my current code. i realize that i have different code sets, i have
tried several other things, none of them working. i am using Access 2000 and
the database is on the local machine, but when finished the database will be
on a server with a shortcut on the local machine.

any help would be greatly appreciated as i am unable to find anything on the
web that is helping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top