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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update new record 1

Status
Not open for further replies.

goobil

Technical User
Aug 9, 2003
38
AG
Hi all,
I am working on the form that list employee hours and i have add a save button
But what i want is when i press the save button the record is save to a new table so i can run the report from that table

Kenneth
kennethg@act2000.net
 
Open the table and add the data. I am sure there is code in the FAQ that will show you how to do that. All the tipmasters have written the code in answer dozens of times.


Rollie E
 
I just checked and did not find one soooo....


dim rs as dao.recordset

set rs = currentdb.openrecordset("NuTable")

rs.addnew
rs("FieldOne") = me![FieldOne]
rs("FieldTwo") = me![FieldTwo]
.... ditto other fields ....
rs.update
rs.close
set rs = nothing

This should do it.

Rollie E
 

Thanks Rolliee
I have a clear understand know of what im doing but i am getting a "TYPE MISMATCH" Error.
Below is the code behind the save button.

option Compare Database
Option Explicit

Private Sub Comsave_Click()
On Error GoTo Err_Comsave_Click
Dim xname As String
Dim xreghours As Integer
Dim xovertime1 As Integer
Dim xovertime2 As Integer
Dim xSick As Integer
Dim rs As ADODB.Recordset
'Dim rs As DAO.Recordset

Set rs = CurrentDb.Openrecordset("update_employee")

xname = Me.Cbo21
xreghours = Me.RegHoure
xovertime1 = Me.OTx1
xovertime2 = Me.OTx2
xSick = Me.sick_hrs

If IsNull(Me.Cbo21) Then
MsgBox "Pleaase select a employee name."
Exit Sub
End If
If IsNull(Me.RegHoure) Then
MsgBox "Please Enter the Regular hours"
Exit Sub
End If

rs.AddNew
rs("fullname") = Me!xname
rs("reghours") = Me!xRegHoure
rs("overtime1") = Me!xovertime1
rs("overtime2") = Me!xovertime2
rs("sick") = Me!xSick


'rs("FieldTwo") = Me![FieldTwo]
rs.update
'DoCmd.GoToRecord , , acNewRec

rs.Close
Set rs = Nothing
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Comsave_Click:
Exit Sub

Err_Comsave_Click:
MsgBox Err.Description
Resume Exit_Comsave_Click

End Sub
 
You forgot to go to the design mode and press Tools/ References and place a check in the MS DAO 3.6 Library. You are using the DAO protocol and your computer is using the ADO. That check mark will pu things right.

Glad you understood it.


Rollie E

If this is helpful click the "Mark this post as helpful..."
 
Yes that work and thanks allot


And thanks every one

Kenneth
kennethg@act2000.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top