eding and Updating Record

osimini

New member
Local time
Today, 12:22
Joined
Aug 23, 2001
Messages
7
Here is the problem. I have table called tblclaimproduction with production records in it. Also, I have a form frmProdEdit with unbound fields. I want to be able to edit the record entered into the tblClaimProduction using the form frmProdEdit. I wrote the following to do this but nothing happens. Even no record pulls up. How can I accomplish this. Below is the code that I wrote.

Private Sub cmdEdit_Click()

Dim rs As Recordset
Dim db As Database

Set db = CurrentDb()
Set rs = db.OpenRecordset("tblClaimProduction", , dbOpenTable)
rs.Edit
rs.ProdDate = Forms![frmProdEdit]![txtProdDate]
rs.AetnaID = Forms![frmProdEdit]![txtAetnaID]
rs.ProcessorID = Forms![frmProdEdit]![txtProcesorID]
rs.Network = Forms![frmProdEdit]![cbo_Network]
rs.ProductID = Forms![frmProdEdit]![cboProductID]
rs.CategoryID = Forms![frmProdEdit]![cboCategoryID]
rs.ProdType = Forms![frmProdEdit]![cboProdType]
rs.QtyClaimsProd = Forms![frmProdEdit]![txtQtyClaimsProd]
rs.ActualWorkHrs = Forms![frmProdEdit]![txtWkdHrs]
rs.OTHrsWkd = Forms![frmProdEdit]![txtOTHrs]
rs.DwntimeHrs = Forms![frmProdEdit]![txtDwnTimeHrs]
rs.LastUpdate = Forms![frmProdEdit]![txtLastUpDate]
rs.Lname = Left$(Trim$(Forms![frmProdEdit]![txtLName]), 20)
rs.Fname = Left$(Trim$(Forms![frmProdEdit]![txtFName]), 20)
rs.MI = Forms![frmProdEdit]![txtMI]
rs.UpdateID = Forms![frmProdEdit]![txtUpDateID]
rs.Update
rs.Close

End Sub


Please I need somebody help.

Thanks
 
If you want to edit existing information within your table, then you would have to use a "Find" Method to move to the specific row within the table to edit the information. Look up Find in the help files as there are a number of ways to achieve this. One of the ways you can do it is to set up your criteria based upon your primary key field in the table and the field name in your form. (For this example, I have used ClaimID]

Criteria = "[ClaimID] = " & [ClaimID]
rs.FindFirst Criteria
rs.Edit ....... etc

An easier way would be to set the forms recordsource to your table/query, and use an unbound combo box to retrieve the actual record that would display all of the existing information. You can then see what was entered and edit as needed.



[This message has been edited by Carol (edited 08-23-2001).]
 

Users who are viewing this thread

Back
Top Bottom