Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21100

Add/Edit entry to Access DB help.

$
0
0
Good afternoon,
I'm starting to get the hang of this but I feel like I may be confusing myself yet again.

I have the below. It connects to my database fine. Then loads records into the listview. This all works great.
Now I am after two things and I've scoured the internet forever but there are so many different examples, I am not sure which one applies to me. I've tried multiple examples but have gotten no where.

I need to be able to "add" record to the end of the database, and "edit" a record

It seems to me that the adding portion would be easiest.

Below is my code that populates the listview.

Code:

Private Sub Form_Load()

Dim myConn As ADODB.Connection

Set myConn = New ADODB.Connection
myConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Business Intelligence\VB6\database9.mdb;"
myConn.Open

Dim strSQL As String 'our query string
Dim oRS As ADODB.Recordset 'our recordset object

Dim lvwItem As ListItem 'this is necessary to directly reference the ListView control
Set oRS = New ADODB.Recordset

strSQL = "SELECT Identifier, Date_Entered, Loan_Number, Investor, State, Doc_type, Description, Number_Pages,Tracking_Number,Address, Processor, Reviewer1, executor1, Reviewer2, Executor2, Notes, Attorney, PLX, Clarifire_Completion, Attorney_Confirmation  FROM MailTeamTracker "

oRS.Open strSQL, myConn
 
'load the listview
Do While Not oRS.EOF
  Set lvwItem = ListView1.ListItems.Add(, , Format(oRS.Fields.Item("Date_Entered").Value, "mm/dd/yyyy"))
 
  lvwItem.SubItems(1) = oRS.Fields.Item("Loan_Number").Value & ""
  lvwItem.SubItems(2) = oRS.Fields.Item("Investor").Value & ""
  lvwItem.SubItems(3) = oRS.Fields.Item("State").Value & ""
  lvwItem.SubItems(4) = oRS.Fields.Item("Doc_Type").Value & ""
  lvwItem.SubItems(5) = oRS.Fields.Item("Description").Value & ""
  lvwItem.SubItems(6) = oRS.Fields.Item("Number_Pages").Value & ""
  lvwItem.SubItems(7) = oRS.Fields.Item("Tracking_Number").Value & ""
  lvwItem.SubItems(8) = oRS.Fields.Item("Address").Value & ""
  lvwItem.SubItems(9) = oRS.Fields.Item("Processor").Value & ""
  lvwItem.SubItems(10) = oRS.Fields.Item("Reviewer1").Value & ""
  lvwItem.SubItems(11) = oRS.Fields.Item("Executor1").Value & ""
  lvwItem.SubItems(12) = oRS.Fields.Item("Reviewer2").Value & ""
  lvwItem.SubItems(13) = oRS.Fields.Item("Executor2").Value & ""
  lvwItem.SubItems(14) = oRS.Fields.Item("Notes").Value & ""
  lvwItem.SubItems(15) = oRS.Fields.Item("Attorney").Value & ""
  lvwItem.SubItems(16) = oRS.Fields.Item("PLX").Value & ""
  lvwItem.SubItems(17) = oRS.Fields.Item("Clarifire_Completion").Value & ""
  lvwItem.SubItems(18) = oRS.Fields.Item("Attorney_Confirmation").Value & ""
  lvwItem.SubItems(19) = oRS.Fields.Item("Identifier").Value & ""
   
  oRS.MoveNext
Loop

    oRS.Close

Now I have a series of textboxes that correlates with each of these fields. Basically what I need to do is take the values in these textboxes and create a new record at the end of the database.

Code:

DTPicker1.Value
txtLoanNumber.Text
cboInvestor.Text
cboState.Text
cboDocType.Text
txtDescription.Text
txtPages.Text
txtTracking.Text
txtAddress.Text
cboProcessor.Text
cboReviewer.Text
cboExecutors.Text
cboReviewer2.Text
cboExecutors2.Text
txtNotes.Text
cboLawFirm.Text
cboYesNo1.Text ('Clarifire_Completion' Field)
cboClarifireTask.Text
cboYesNo2.Text ('Attorney_confirmation' Field)

Thank you so much in advanced!

Viewing all articles
Browse latest Browse all 21100

Trending Articles