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
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 May 25th, 2005, 12:05 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing data between forms

I have two tables in MS Access DB with corresponding forms. In Form A, I have a text box (TextfieldA)and in Form B, I have another textbox (Textfield B). I have the database setup so that the end-users have to enter information in Form A and then, they have to enter the same information in Form B. I know how to set it up so that the end-user can select the data that they entered in Form A using a pull-down menu utilizing a query but is there a way to do this more efficiently using codes or Macros? If so how?

Any help would be greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old May 27th, 2005, 08:58 AM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Additional information:
Only TextField B in Form B share same information as Textfield A in Form A.

Reply With Quote
  #3 (permalink)  
Old May 28th, 2005, 09:10 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

It's a little unclear what you want. I'll focus on the description about users entering data, though you could be asking about a more efficient way to allow entry in TextfieldA.

When you say the users have to enter the same information in Form B, does that mean you want to make them double-type the information to be sure they entered the correct information? Or are you trying to build a user friendly application where after they enter information in form A it automatically populates to form B?

In either case, you're looking at using either the BeforeUpdate event on textfieldB (if you want to make sure they entered the same value and error if not) or AfterUpdate event on textfieldA (if you want to auto-populate formB).

What you need to know is how to reference the field of the other form. This is done using the Forms collection, as follows:

Forms("formname").textfieldcontrolname

E.g. Forms("FormB").TextfieldB to for the AfterUpdate event situation.

One thing that you'll probably want to do is be sure that the other form is open. This can be done by checking

If CurrentProject.AllForms("formname").IsLoaded Then

Not that it's my business, but why do you have two forms that display the same information opened at the same time? If they are so related, why not make one of them the master form and the other a subform?

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
Reply With Quote
  #4 (permalink)  
Old May 30th, 2005, 12:44 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mr. Weers;

Sorry for the poor discription about my problem but your second guess about auto-populating Textfield B is correct. TextField B is the only field with same value. The rest of the information on the Form B is different. Your guess about trying to build a friendlier database is also correct. I am creating this DB as a side project at my work and the users are going to be people who never used a computer before so even though, the information is duplicative, I thought it would be easier for the ens-user to perform a simple query if all the information is in the same table.

Thank you for your assistance and can I ask for little more. Can you tell me how your codes would work and do I need to add more info.

Reply With Quote
  #5 (permalink)  
Old May 31st, 2005, 07:03 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think this is one where you're going to have to hack through mostly on your own. But here's a little code that will do what you asked.

For the TextfieldA_AfterUpdate event, write something to the effect of:
Code:
' make sure the form is open
If CurrentProject.AllForms("formname").IsLoaded Then
    ' make sure we should populate the text field
    If isnull(Forms("formname").TextfieldB) then
        Forms("formname").TextfieldB = Me.TextfieldA
    End If
End If
The trouble is, there probably is a lot of code that needs to go into checking to be sure Form B is ready to receive the data from Form A. Questions like "has the user changed the data on Form B and should it be saved before we send data from From A?" have to be asked.

Without knowing more about how your users are using the forms (e.g. are the forms strickly data entry (new records), or will they use Form A to initiate a lookup and do you want to have form B automatically show information related to form A) and why you have chosen to use two forms instead of master and sub (child) form, there's really not much I can do other than tell you the code that will do what you asked which was to "auto-populate the data from form A to form B".
Reply With Quote
  #6 (permalink)  
Old June 4th, 2005, 03:02 PM
Registered User
 
Join Date: May 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Mr. Weer,

Again, thank you for your assiatance and if you are still interested in providing more assistance, please read on.

Concerning user interface, Form A is the first user entry point and the only data entry point from the switchboard. The user will not have access to Form B until they have entered all the information on Form A and the Form B only opens when, the user answers a question on a yes or no button. If they click, "yes," the form B opens and closes the Form A. If they click, "No," then the Form A either provides an option of going to a new record on the Form or closing the form.

Hope this shed some light into the issue.

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
passing data on multiple forms dzisaacs C# 2 December 6th, 2007 02:03 PM
Passing Parameters Between Two Forms sjf905 C# 2 January 13th, 2007 10:44 PM
Passing data between forms rwalker VS.NET 2002/2003 6 February 17th, 2005 08:17 AM
Passing values between forms alok992 C# 1 April 28th, 2004 04:07 AM



All times are GMT -4. The time now is 02:24 PM.


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