write to access from vb 
Author Message
 write to access from vb
What VB code will write simple strings and numbers to the tables of an
access database?

hanspeter amend



Fri, 12 Apr 2002 03:00:00 GMT
 write to access from vb

wouldn't the DAO recordset methods work here?  I typically use .additem and
.update within Access to write new data to a recordset.  Something like
this:

with rst
    ,additem
    !Some Field in the recordset=some value form the VB form
    .update
end with

Now of course all of this is after the recordset has been dimensioned and
set to the Access Database.

I would tend to think this would work.  If I am wrong I apologize, but would
be curious as to whether or not it works, and if not then what does.

I just thought of another way to do this.  You can use an INSERT INTO SQL
statement  to update the table in question with the new data.

Now I do know this will work.

Hope this helps

Paul

--
Visit Eco-Tron, Inc for your hazardous and Industrial
waste management needs at www.ecotroninc.com

Hanspeter Amend wrote

Quote:
> What VB code will write simple strings and numbers to the tables of an
> access database?

> hanspeter amend



Fri, 12 Apr 2002 03:00:00 GMT
 write to access from vb

Quote:

> What VB code will write simple strings and numbers to the tables of an
> access database?

If you've opened a DAO recordset (named rsAmend) for the table:

rsAmend.AddNew  'to add a new record - OR -
rsAmend.Edit  'to add/revise field data for an existing record

rsAmend!Field1_Name = strSomeString
rsAmend!Field2_Name = intSomeNumber
rsAmend.Update

  With ADO, you can skip the .Edit statement;  with ADO, editing is
automatically invoked .

  Another option is to open the db with code, then Execute an SQL INSERT
statement:

strSQL = "INSERT INTO SomeTable (Field1_Name, Field2_Name) VALUES " _
         & "('" & strSomeString & "', " & intSomeNumber & ")"
db.Execute strSQL

--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"

"What's so funny 'bout peace, love & understanding?"
     - Nick Lowe



Fri, 12 Apr 2002 03:00:00 GMT
 write to access from vb
So Jim, I take it you were affirming what I said?  So I was right about
either way then? Cool.  I have learned something then.

Paul

--
Visit Eco-Tron, Inc for your hazardous and Industrial
waste management needs at www.ecotroninc.com

Jim in Cleveland wrote

Quote:
> If you've opened a DAO recordset (named rsAmend) for the table:

> rsAmend.AddNew  'to add a new record - OR -
> rsAmend.Edit  'to add/revise field data for an existing record

> rsAmend!Field1_Name = strSomeString
> rsAmend!Field2_Name = intSomeNumber
> rsAmend.Update

>   With ADO, you can skip the .Edit statement;  with ADO, editing is
> automatically invoked .

>   Another option is to open the db with code, then Execute an SQL INSERT
> statement:

> strSQL = "INSERT INTO SomeTable (Field1_Name, Field2_Name) VALUES " _
>          & "('" & strSomeString & "', " & intSomeNumber & ")"
> db.Execute strSQL



Sat, 13 Apr 2002 03:00:00 GMT
 write to access from vb

Quote:

> So Jim, I take it you were affirming what I said?  So I was right about
> either way then? Cool.  I have learned something then.

  I hadn't seen your post when I replied - if I had, I wouldn't have
wasted the electrons with my post 'cause you were right on both counts!
People gotta love it when they ask for a solution and you give 'em 2 for
the price o' one.
--
Jim


Sat, 13 Apr 2002 03:00:00 GMT
 write to access from vb
Thank-you Jim for the backup support.  I sometimes wonder if I am on the
right track or not.  It is nice to get this kind of support from my peers.

Thank-you once again

Paul

P.S. Jim email me if you can.  Where in Cleveland do you work?  I am in
North Canton. I have a few questions I would like to run past you.  Thanks
--
Visit Eco-Tron, Inc for your hazardous and Industrial
waste management needs at www.ecotroninc.com

Jim in Cleveland wrote

Quote:

> > So Jim, I take it you were affirming what I said?  So I was right about
> > either way then? Cool.  I have learned something then.

>   I hadn't seen your post when I replied - if I had, I wouldn't have
> wasted the electrons with my post 'cause you were right on both counts!
> People gotta love it when they ask for a solution and you give 'em 2 for
> the price o' one.
> --
> Jim



Sun, 14 Apr 2002 03:00:00 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. Write Access on D3Linux through VB

2. Empty field writing back to Access DB from VB

3. dbf read/write using access/vb (win AND dos)

4. reading and writing to/from an Access db from VB

5. error writing date field to Access 2000 using SQL statement in VB 6

6. Confused newbie: How to write a new record to an Access database from VB.

7. VB 3.0 - Problem writing to Access database on second machine

8. VB 3.0 - Problem writing to Access database on second machine

9. Looking for Help writing VB/Access Daatabase App

10. Access 2.0 read/write from VB??

11. Writing into an OLE obj field on MS Access via VB

12. read write error when attempting to write to dbo_tblCounts (Access linked table)


 
Powered by phpBB® Forum Software