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?