you have several issues here. first, you should rename the table field
called "Name", which is an Access Reserved Word and should NOT be used as
the name of anything *you* create in the database, including tables, fields,
queries, forms, reports, form/report controls, macros, modules and
procedures. for more information, see
http://home.att.net/~california.db/tips.html#aTip5.
next, a person's age is a calculated value based on his/her date of birth
subtracted from the current date. storing a calculated value in a table is
considered poor design. the only exception i can think of would be if the
record is historical data and you have a business need to know what the
person's age was *at that point in time*, rather than their current age.
even then, i'd probably date-stamp the record, and calculate the age using
that date, rather than storing a hard age value.
next, if you only have one field for the name, and if we're talking about
people here (not businesses, organizations, etc), then you are breaking
normalization rules, which require atomic data storage - separate fields for
first name, last name, middle name or initial if it's needed. suggest you
read up on relational design principles; for more information, see
http://home.att.net/~california.db/tips.html#aTip1.
now, having said all of the above, what is the RecordSource of frmDataEntry?
if the RecordSource is blank, then enter tblPeople in that property. now the
form is bound to tblPeople. set the ControlSource property of txtName to
Name, and the ControlSource of txtAge to Age. now you can just enter the
name and age in the form, and the values will be written to a new record in
the underlying table.
if frmDataEntry is already bound to another table (not tblPeople), you can
run an Append query to add the name and age to tblPeople (refer back to the
comments above re table design), as
CurrentDb.Execute "INSERT INTO tblPeople ( Name, Age ) " _
& "SELECT '" & Me!txtName & "', " & Me!txtAge
the above SQL statement's syntax assumes that the Name field in tblPeople
has a Data Type of Text, and the Age field has a data type of Number.
but i strongly urge you to read up on relational design principles and
reconsider your table design before moving forward.
hth
"RICHARD BROMBERG" <dickbrom@worldnet.att.net> wrote in message
news:IeXTk.135606$Mh5.97332@bgtnsc04-news.ops.worldnet.att.net...
> I am using Access 2000 and I would like to make a data entry form
> (frmDataEntry)
>
> I want to append a newrecord to a table (tblPeople) and populate the new
> record from two Textboxes (txtName and txtAge) The table has two fields,
> Name and Age.
>
> I used a command button (the command button wizard, record operations,Add
> New Record) and it generates the code snippet below.
>
> I think I have to add some code in the area I marked with question marks
in
> the snippet, something like:
> XXXXXXX = Me.txtName and YYYYYYYY = Me.txtAge.
>
> How do I refer to the Name and Age fields in the new record?
>
> Help would be greatly appreciated.
>
> ******************** snippet ***********
> Private Sub commandAddRecord_Click()
>
> On Error GoTo Err_commandAddRecord_Click
> DoCmd.GoToRecord , , acNewRec
> '
> ' ?? move data from textboxes to table??
> '
> Exit_commandAddRecord_Click:
> Exit Sub
>
> Err_commandAddRecord_Click:
> MsgBox Err.Description
> Resume Exit_commandAddRecord_Click
>
> End Sub
>
> ******************** snippet ***********
>
>