On Sat, 23 Jul 2005 10:25:50 -0400, Kissi Asiedu wrote:
I am trying to find a way to append data from a user into a table using Code
module. Here is an example:
I have a table "SHORTS" and fields "DATE" and "SHORT". I wrote the code
below but access won't recognize the fields. Can some one Help please.
Dim strShorts as Sting
Dim dtShort as Date
dtDhort = Date
strShorts = inputbox ("Enter Shorts", "Today's Shorts")
[SHORTS]![DATE] = dtShort
[SHORTS]![SHORT] = strShorts
Date is a reserved Access/VBA/Jet word and should not be used as a
field name.
Change the field named "Date" to something else, perhaps "SaleDate".
See the Microsoft KnowledgeBase article for your version of Access:
109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
How you update the table depends upon other factors.
Where did you place this code? In a form's Code Module, or in an
Application Module?
In a Form module, if [YourDateField] and [Short] are included in the
form's record source, you can use:
(Note that strShorts in your example above is Dimmed as Sting.
It should be String. However, there is no need to Dim any variables.)
[YourDateField] = Date ' Enter the current date into [YourDateField]
[SHORT] = inputbox ("Enter Shorts", "Today's Shorts")
In an Application Module run an Update query (look up Update Query in
Access help) or open the recordset and make the change directly.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.