0
votes

I am planning to insert value in a vba access form text box values to the table in same access file

Here i will write a insert query on the submit button click event

Is there any shortcut methods to add the value into the table?

Like seting the datasource for the textbox and inserting values of all textbox in the form using a click of button

without insert queries ????

which is better?

1

1 Answers

0
votes

Not sure exacly what it is that you are asking.

To add rows to a table in VBA code you can use a DAO Recordset like this:

Dim rs As DAO.Recordset
Set rs= CurrentDb.OpenRecordset("TableName", dbOpenDynaset)

rs.AddNew
rs![ColumnName1] ="Some Value"
rs![ColumnName2] ="Some Value"
rs.Update
rs.Close

Or to run an Append Query in VBA build the SQL Statement in to a string and execute the statement like this:

CurrentDb.Execute strSQLText, dbFailOnError