Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Current Record in a Form to a Table Using Command Button

Status
Not open for further replies.

samn265

Technical User
Feb 12, 2002
35
US
I have a form that gets data from a query. The query might have many records; therefore, the form has the same number of records.

I made a Command Button on the form to transfer the current record data that I am viewing, to a table. Thus, only the data I am viewing is supposed to be transferred.

The problem I am having is regardless of what record I am viewing, only the 1st record is transferred. I guess I don't know how to do this procedure! I appreciate any input that you might provide.

Here is my code:

Private Sub Accept_DblClick(Cancel As Integer)
Dim db As Database
Dim rst1 As Recordset
Dim rst2 As Recordset

Set db = CurrentDb
Set rst1 = db.OpenRecordset("Table1")
Set rst2 = db.OpenRecordset("qryListOfNeededReviewedDocs")

rst1.AddNew
rst1!DocNumber = 1
rst1!ReviewStatus = "Accepted"
rst1.Update

'rst2.AddNew
Msgbox rst2!DocNumber
'rst2!DocNumber= rst2!DocNumber
'rst2.Update

rst1.Close
rst2.Close
db.Close
End Sub



Thanks
East or West Home is Best.
 
OK, so I assume Table 1 is where you want the data to go...?

First off, instead or reopening the query as a new recordset you could make rst2 = Me.RecordsetClone if the form is bound to the query (which I'm guessing it is...)

Could you give me a list of fields that you want appendded to Table1 from your query and what is your unique identifier (Primary Key)?

There are a couple ways to do this... Kyle [pc1]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top