How do I save field data on a Form to a table?

  • Thread starter Thread starter Angus Comber
  • Start date Start date
A

Angus Comber

Hello

I have fields on a form. The fields are unbound. I have checked values and
now want to save to a table called MyTable. how do I do that?

AC
 
You'll have to write an INSERT query to take the values from the form and
populate the table.

Dim strSQL As String

strSQL = "INSERT INTO MyTable (Field1, Field2, Field3) " & _
"VALUES(" & Me.Text1 & ", '" & Me.Text2 & "', " & _
Format(Me.Text3, "\#mm\/dd\/yyyy hh\:nn\:ss\#") & ")"
CurrentDb.Execute strSQL, dbFailOnError

The above assumes that Field1 is numeric, Field2 is text and Field3 is
Date/Time.
 
Angus,

It would have been easier for you as I'm sure you know if you had bound the
fields to fields in the table. Barring that, you can write DAO or ADO code
to open the recordset "mytable", move the data field by field, and write a
record. Or, you could do an "Insert into...." sql command and add a table
record that way.

S
 
Angus Comber said:
Hello

I have fields on a form. The fields are unbound. I have checked values
and
now want to save to a table called MyTable. how do I do that?

My very strong suggestion is that you bind the Form to a Query or Table,
because using unbound Forms and code not only means you are re-inventing,
re-implementing, and re-testing capability that is the primary reason people
find Access so useful, but that you are costing yourself, your employer, or
your client unnecessary time and money.

If you feel compelled to stick with the unbound Form, Doug has already
responded.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top