Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Writing Data To Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J - 05 Jan 2006 18:08 GMT
Just wondering how I would write data to a table on a button click
after i have entered the data into a form.  All help appreciated.
freakazeud - 05 Jan 2006 18:48 GMT
Hi,
you could just make the form bound and then when the record loses focus it
will save the data to the appropriate fields. If this is unbound you could
use code like this:

Dim rs As New ADODB.Recordset
Dim varItem As Variant

rs.Open "tblYourTable", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic

rs.AddNew
rs!Field01 = Me.YourControl01
rs!Field02 = Me.YourControl02
rs.Update

rs.Close
Set rs = Nothing

HTH
Good luck
Signature

Oliver
Admin Specialist & Computer Science Major @ UMD - Go Terps - :)

> Just wondering how I would write data to a table on a button click
> after i have entered the data into a form.  All help appreciated.
Kou Vang - 05 Jan 2006 21:26 GMT
If you don't want to deal with VBA, you could use a Macro to run a Query.
Create an Append Query based on your table.  Choose your table as the Append
Table or target table.  In the Criteria portion of the Query, you will put
the controlnames as the condition. Exp:

[Forms]![YourFormsName]![YourTxtBox]

Then on the click event, choose Macro.  On the Action pull down, select
OpenQuery.  In the Action Arguments Box at the bottom, select your Query
Name, and Data mode.  Save your Macro and exit.  

When you click the button, it should run the Append Query, and update your
table.  Macros are easy to use for certain situations.  Once you become more
familiar with VBA, it allow you greater flexibility to modify actions on the
fly.  Good Luck!

> Just wondering how I would write data to a table on a button click
> after i have entered the data into a form.  All help appreciated.
J - 06 Jan 2006 12:43 GMT
I'm still having some problems. I set up the macro to run the query but
apparently it's saying "You are about to append 0 Rows"  Some data that
I have is:

Field: Quantity
Table: Inventory Table
Sort:
Append To: Quantity
Criteria:  [Forms]![Inventory Entry Screen]![Quantity]
Or
Kou Vang - 06 Jan 2006 15:22 GMT
Okay, I know what I told you wrong now.  Instead of filling out the criteria
portion of the query, we'll just put it right into the field.  In the field
write:

Field: Quantity: [forms]![Inventory Entry Screen]![Quantity]

Do this for all the controls you want to populate in your table.

Leave the Table: blank and the Criteria: blank and it should work now.  Let
me know if it doesn't.  Good luck.

> I'm still having some problems. I set up the macro to run the query but
> apparently it's saying "You are about to append 0 Rows"  Some data that
[quoted text clipped - 6 lines]
> Criteria:  [Forms]![Inventory Entry Screen]![Quantity]
> Or
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.