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
| 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 Search this Thread Display Modes
  #1 (permalink)  
Old March 3rd, 2005, 04:30 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding records using form and subform

I need someone to get me started,
I have two tables:
   tCon: tTrans:
   ConID TransID
   EnvNo EnvNo
   Name Money
   Desc

This is suppose to work like a bank account. I need to make a form with a subform so that I can type in an [EnvNo] in a textbox and in the subform it will display the [Name] and [Desc] for that EnvNo. That was the easy part because I got it to work the other part is that the main form has a textbox for [Money]. After a user types in an [EnvNo] and the information displays below in the subform, they can then type in the [Money] and press a commmand button. This is suppose to add a record to [tTrans] with the current [EnvNo] and that money. I got this to work but it only is able to add it once. If I was to press the command button again after adding one amount it just replaces the previous records money amount without adding a new record with a new transaction.

Please I need some help.

Reply With Quote
  #2 (permalink)  
Old March 4th, 2005, 12:53 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I have a few questions here about the structure of these tables, and how they are used in the forms.

I will assume this:

tCon
ConID - PK
EnvNo - FK (should go to TransID, not EnvNo, even if this is what is displayed)
Name - text
Desc - memo

tTrans:
TransID - PK
EnvNo - text or number
Money - Currency

If you create a form using AutoForm (for example) while on the tCon, or primary, table, then you have the tCon table data showing on the main form, and the tTrans table showing up in the subform.

Question:
1. Why is there a text box on the Main tCon form to enter tTrans.Money when that field is available on the subform already?

2. If you want to give the user the option to view the data in the subform in normal form view, why not have a button to switch between formview and datasheet view in the subform, rather than have data entry for the subform on the main form?

A more elegant way to do this if you want the data entry form to LOOK like the main form is to create a form on tTrans, and then create a query and subform to show the tCon data (locked) on the top of the tTrans form. You could even have the tTrans form show the complete tTrans data for that tCon account at each record.

For that matter you could also use the autoform wizard to creat the main form and subform - both in form view, then add a second subform showing the tTrans table in datasheet view below the first subform. As transactions are entered in the first normal subform, requery the second datasheet tTrans subform.

In any event, I wouldn't rely on an unbound text box and button to put data into a table when bound forms work more reliably.

HTH



mmcdonal
Reply With Quote
  #3 (permalink)  
Old March 4th, 2005, 01:00 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, Make the main form on tTrans, but the observations are the same.

mmcdonal
Reply With Quote
  #4 (permalink)  
Old March 7th, 2005, 04:37 PM
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for the late response, was away for a couple days.

My problem is that on the main form (tTrans) i don't have a textbox bound, I have a unbound textbox which I want the user to type a money amount and click save. And this saves to the record to tTrans. The EnvNo would be what is selected in the first textbox. I am able to add this to the record but I want it to be able to add two records if I pressed the command button twice. And Add new record did not work. Not sure if the subform is not letting me add more then one record until i leave the form.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Subform not displaying values after adding updates jlangdon Access 1 April 23rd, 2008 03:00 PM
Autopopulate Subform with New Records Odeh Naber Access 0 August 2nd, 2007 04:29 AM
filtering records on subform from an unbound combo jd_erd Access 3 February 12th, 2007 11:21 PM
Looping through subform records V Access VBA 8 April 20th, 2004 08:10 AM
records in subform stoneman Access 1 October 27th, 2003 11:46 AM



All times are GMT -4. The time now is 01:15 AM.


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