Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 3rd, 2005, 08:04 PM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding records to Tables

Hello All. I am very green with Access programming and I and trying my hand at something new here so please be patient.

Can someone oint me to a good example of writing multiple records to a single table using a single form?

My task is that I have one form that I enter data on and each "row" of data entered needs to be saved in a signle table.

I have Beginning Access 2000 VBA. Not finding much on this or better, I don't knwo how to look for a topic that would describe what I am trying to accomplish.

Thanks for any help.

Lance

Reply With Quote
  #2 (permalink)  
Old January 6th, 2005, 01:39 AM
Friend of Wrox
 
Join Date: Dec 2004
Location: Chennai, Tamil nadu, India.
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

For access you could check: http://mvps.org/access/

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
Reply With Quote
  #3 (permalink)  
Old March 10th, 2005, 03:19 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm doing somthing similar, but can't seem to find help on this site or the one linked above. I'm using a form to grab and parse a text file. This data is used to add multiple records to multiple tables. I know forms are typically linked to a single table, but will VBA let me add records to any table I like? If so, I'd really appriciate the beginnings of some code.

Thanks in advance.

Reply With Quote
  #4 (permalink)  
Old March 10th, 2005, 08:01 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Keep in mind, that to do this your attitude must be “I have the control!

[u]You</u> know the names of the controls on the form, so, when it is time to save the data, open a recordset, add a new record to it, and read the values of the controls for the first record into the fields of the recordset by using their names (eg, r!Addr = Me.txtbxAddr_1.text).

Once all the fields are filled, .Update the record, add another record, and read the controls for record number 2 into the fields of the recordset, again by using their names (eg, r!Addr = Me.txtbxAddr_2.text). The recordset fieldnames will be the same each time (but you will have created a new record), but the names of the controls from which the info is coming will be different, according to how you have named them.

Keep doing this until you have read all the controls.

You probably should add a test for each “row” to avoid adding any records for non-existent data.
Reply With Quote
  #5 (permalink)  
Old March 11th, 2005, 06:31 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah, I know that much (though I'm still trying to iron out the details in code). My problem is that, according to my understanding, a given form can only be associated with a single table of data. I want to change two different tables with one button click. Am I misunderstanding how a recordset is opened?

I would really appriciate some example code if you've done anything like this before. I think that would help me better understand what's going on. Thanks again for any help you can provide.

Reply With Quote
  #6 (permalink)  
Old March 16th, 2005, 04:12 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found my own answer. If anyone else has a similar problem, this site helped me a lot to combine VBA and SQL: <http://www.fontstuff.com/access/acctut16.htm>

Reply With Quote
  #7 (permalink)  
Old March 20th, 2005, 07:23 AM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I can help you with code, but you have to be specific. VBA help in createTabledef will give you lines for adding records to a table.
Multiple means to loop in the same procedure:
For...Next, Wile...Wend, Loop Until...End Loop.


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding records to db djobes31770 VB Databases Basics 3 November 27th, 2007 09:27 AM
Adding Records with VBA rohit_ghosh Access VBA 7 June 22nd, 2007 06:05 AM
adding multiple records Vince_421 VB Databases Basics 4 February 28th, 2007 07:22 AM
adding records sinner Classic ASP Databases 5 February 25th, 2004 06:12 PM



All times are GMT -4. The time now is 09:50 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.