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

insert new record on button click

Status
Not open for further replies.

misubud

IS-IT--Management
May 29, 2002
25
NZ
New Record on button click.
I have a number of fields on a form. On a Command Button click I need to be able to add the info from the fields to an existing table as a new record.

For example:
Take the info from Text1 & Text2 and put it as new record in the table called 'tblTime' under the fields 'Start' (for text1) and 'Finish' (for text2).

I don't really want to have to see the table at time of input, Just pass the values in as a new record.

Any assistance would be much appreciated.

Regards
Colin
 
at the button click select code builder
inside the code window
it should look like this

Option Compare Database
Option Explicit

Private Sub Button1_Click()
DoCmd.Setwarnings false
docmd.runsql " INSERT INTO tblTime (Start,Finish) values(Forms!MyForm!Text1,Forms!MyForm!Text2) "
DoCmd.Setwarnings true
End Sub


PS: Type in your forms Name instead of MyForm

Best of luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top