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 / New Users / March 2005

Tip: Looking for answers? Try searching our database.

how to add data inseted on a form into a database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rob - 26 Mar 2005 18:21 GMT
I have created a form with these 5 fields Txtdate, txtname, txtaddress,
txtphone and txtfax. When I enter these fields I want to save it back to the
table i've created called members which have the same names as the field
names on the form. This is what I have done so far
option explicit
dim rst as recordset
dim db as database
dim count as integer

in the save command i have

Private sub cmdsave_click()
set db = current db
if xcount = o then
set rst = db.openrecordset("select * from members")
with rst
.addnew
!txtdate = txtdate
!txtname = txtname
!txtaddress = txtaddress
!txtphone = txtphone
!txtfax = txtfax
.update
end with
rst.close
db.close
end sub

unknown to me this doesn't work. Please help?
Duane Hookom - 26 Mar 2005 19:42 GMT
Did you try to compile? Do you know you can copy and paste your exact code
into a message? When you say "this doesn't work" you are short changing us
by not providing a more descriptive symptom.

   current db
should be
   CurrentDb

   dim rst as recordset
   dim db as database
should be
   Dim rst As DAO.Recordset
   Dim db As DAO.Database

You have dim'd xcount and I expect
   if xcount = o then
should be
   If xcount = 0 Then
What are you doing with xcount or count? If you dim an integer memory
variable, you should name the variable intCount or similar.

I would probably execute an INSERT SQL statement rather than opening a
recordset but that is up to you.
Signature

Duane Hookom
MS Access MVP

>I have created a form with these 5 fields Txtdate, txtname, txtaddress,
> txtphone and txtfax. When I enter these fields I want to save it back to
[quoted text clipped - 26 lines]
>
> unknown to me this doesn't work. Please help?
 
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.