updating a table using a command button (1 Viewer)

alastair69

Registered User.
Local time
Today, 08:35
Joined
Dec 21, 2004
Messages
562
Hello All,

I have successfully coded a button to copy one line of data, i need to be able to copy any selected records, but i am not sure how to go about this, i have included the coding that i am currently using.

The form is a continuse form.

The Code Is:

Private Sub cmd_Update_Table_Click()

Dim db As Database
'Dim rs As Recordset
Dim frm As Form
Set db = CurrentDb() 'keeping in mind your table is within the same database
Set rs = db.OpenRecordset("tbl Samples")
If [Form]![frm Export]![Chk_ExportTable] = True Then
rs.AddNew
rs!ReportNumber = ReportNumber
rs!SampleNumber = [Form]![frm Export]!Sample

rs.Update
rs.Close
Me.Refresh

MsgBox "RECORD SUCCESSFULLY UPDATED", vbOKOnly, "SAVE INFORMATION"

End If
End Sub

any help or advice will be taken on board and used.

Kind Regards

Alastair
 

alastair69

Registered User.
Local time
Today, 08:35
Joined
Dec 21, 2004
Messages
562
update

Does this need a loop statement or something!!!!!
 

Bat17

Registered User.
Local time
Today, 16:35
Joined
Sep 24, 2004
Messages
1,687
The problem is telling how the rows are selected I think. I can't recall a method at the moment. one option would be too add a check box to allow you to select the records to update and filter on that. another possibility would be to change the subform to a multiselect list box and use it selection property.

HTH

Peter
 

Users who are viewing this thread

Top Bottom