Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I WANT TO ADD INFORMATION IN FIELDS OF A TABLE FROM CODE

Status
Not open for further replies.

arunsule

Programmer
Mar 31, 2002
6
IN
I HAVE A TABLE WITH FIELDS ITEM, RATE
I HAVE A FORM BASED ON ABOVE TABLE
IF I TRY TO ADD VALUES IN TABLE USING INPUTBOX , IT DOES NOT GET ADDED.
IF I OPEN THE FORM IN CODE AND ADD THE INPUTBOX VALUE IN [FORMS]!FORMNAME]![FIELD],IT GETS ADDED.
IS IT NECCESSORY TO OPEN FORM TO ADD DATA IN FIELDS?
CAN IT NOT GO DIRECTLY TO TABLE?
WHICH DOCMD COMMAND I SHOULD USE FOR THIS?
THANKS AND REGARDS
ARUNSULE
 
DONT SHOUT - We can hear you without SHOUTING.

There is no DoCmd for this.

If the Form is not open then you'll need to open a RecordSet and write to the table that way.

Dim rst As New ADODB.RecordSet
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "SELECT * FROM tblTableName WHERE " ' & add clause here to pick correct record

rst!FieldName = ValueToGoIntoField

etc..
etc..

rst.Update
rst.Close
Set rst = Nothing



The above is ADO - applicable for Access 2000 and above.
If you are working on Access 97 or before then let me know and I'll translate it to DAO for you.


'ope-that-'elps.

G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top