Form data to table

gguy

Registered User.
Local time
Today, 22:39
Joined
Jun 27, 2002
Messages
104
I know this is probably very simple but I'm not getting it!

I have a several fields in a form that need to be passed to a log table. I have an exit button on the form and would like the data to be added to the log table automatically through the On Click function.

In the past I have used the code below to pull data from a form to a report, using On open function in the report.

[E_ID] = [Forms]![FRM_E_Edit]![Elevator_ID]

What I want to do now is have the Elevator_ID (and other data) written to the log table when the record is accepted/written in the main table.

Thanks, GG
 
Why don't you just bind your form to that table, and the controls on it to the relevant fields?
 
Dim Db As DAO.Database
Dim rs As DAO.Recordset

'opens Log table and adds a new record
Set Db = CurrentDb
Set rs = Db.OpenRecordset("tblLog")

rs.AddNew
rs("Elevator_ID").Value = Me.Elevator_ID
'etc.
rs.Update

set db = nothing
set rs = nothing

This may not be what you are looking for but I use this on a data entry page where I have unbound text boxes. It saves data to the table 'manually', so to speak. If your controls are already bound to a main table and you wish to save that same data to another table I don't know of any other way.

HTH
 
Glenn

I have not put this in play yet but saving data to a secondary table is exactly what I am trying to do. Thanks for the help. GG
 

Users who are viewing this thread

Back
Top Bottom