How to create new record

T

Tim McGavin

How can i use code to create a new record into a table.

Something like this?

CreateNewRecord("John","Smith")

I tried to Google it but i can't seem to find the answer.

help!
thanks
 
J

John W. Vinson

How can i use code to create a new record into a table.

Something like this?

CreateNewRecord("John","Smith")

I tried to Google it but i can't seem to find the answer.

help!
thanks

Open a Recordset based on the table and use the AddNew method. See the online
help for OpenRecordset and AddNew in the VBA editor.

John W. Vinson [MVP]
 
P

pietlinden

Tim said:
How can i use code to create a new record into a table.

Something like this?

CreateNewRecord("John","Smith")

I tried to Google it but i can't seem to find the answer.

help!
thanks

Is there something you don't like about forms? Or a reason they won't
work for you?

Look up DoCmd.RunSQL in the help.
Or CurrentDB.Execute strSQL (where strSQL is a valid SQL statement)
or you could use a recordset...

Where are you trying to insert the record from?
 
T

Tim McGavin

Look up DoCmd.RunSQL in the help.
Or CurrentDB.Execute strSQL (where strSQL is a valid SQL statement)
or you could use a recordset...

Where are you trying to insert the record from?

Thanks guys your comments helped so much!
 
Top