How do I save data on a form to my database?

A

adamskiii

I am new to Access and was wondering how I would save a record from my forum
to the database. I am using an unbound forum.

Thanks
 
A

Al Campagna

adamskiii,
Why have you created an "unbound" form to operate on a table?

If you're new to Access, you've just made your project much more
difficult than it needs to be.

You'll need to create a button on your form that, when clicked, runs
an Append query against your table, using the current values on the open
form.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
M

Maurice

You would probably open the recordset and write the values from the form to
the table for example:

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

With rst
.Open "YourTable", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
.AddNew
.Fields("tablefieldname") = Me.textboxonform
.Fields("tablefieldname") = Me.textboxonform
.Fields("tablefieldname") = Me.textboxonform
'etc...
.Update
.Close
End With

Set rst = Nothing

replace the "tablefieldname" with the names which you use in the table for
your fields
Replace the "Me.textboxonform" with the names of the textbox controls you
are using on your form.

hth
 
M

Maurice

See my previous posting, it looks a lot like you ave already you just have to
reverse the process.

hth
 
J

Jack Leach

What kind of backend are you using? I assume this is an MSAccess database as
nothing has been noted otherwise... if this is in fact the case, then there
is no reason whatsoever to be using any recordset an all, let alone using ADO!

As Al said, you are going the looooooong way around. If you have a standard
ms access table and form, just use the wizard to make a form that is bound,
and all of this is taken care of for you (using Access's native DAO, not ADO).

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

John W. Vinson

I just believe that I have more control with an unbound form.

Sure, but that means that you must do Every Single Little Thing that Access
does for you automatically. Unbound forms are in fact useful; they are also
slower, much more complex, and far more difficult to create and maintain. Your
choice!
 

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

Top