Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Adding Records from code


Message #1 by "Pavel Margolin" <royalassassin8@a...> on Fri, 20 Jul 2001 04:59:26
Does any one know how to add records from code? I am using visual basic 

and I'm basically reading a text file and inputing it into a database. Is 

there a way to put records into a database without using bound objects?  
Message #2 by "Richard Lobel" <richard@a...> on Fri, 20 Jul 2001 07:17:36 -0700
Use the sql statement InsertInto. The syntax is basically:

Databasename(or CurrentDB is in Access).Execute _

InsertInto SomeTableName (field1, field 2, etc) VALUES (Value1, Value2);

I have found that that to debug easier I first make the whole InsertInto

code line a string variable and then just

Databasename.execute strName

That way if there is something wrong with the InsertInto statement I can

use the Immediate Window to see the current value of it.

Richard Lobel







Message #3 by "Pardee, Roy E" <roy.e.pardee@l...> on Fri, 20 Jul 2001 07:19:56 -0700
Have a look at Help for the .TransferText method of the DoCmd object--that's

probably easiest.  If that doesn't suit, you can always use the low-level

file functions (e.g., Open "c:\MyFile.txt" For Output as #1) and recordset

objects--considerably more trouble.



HTH,



-Roy



-----Original Message-----

From: Pavel Margolin [mailto:royalassassin8@a...]

Sent: Thursday, July 19, 2001 9:58 PM

To: Access

Subject: [access] Adding Records from code





Does any one know how to add records from code? I am using visual basic 

and I'm basically reading a text file and inputing it into a database. Is 

there a way to put records into a database without using bound objects?  

---


  Return to Index