A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

automatically fill field with form information



 
 
Thread Tools Display Modes
  #1  
Old January 13th, 2005, 08:45 PM
Tina L.
external usenet poster
 
Posts: n/a
Default automatically fill field with form information

I have a form for COMPANY, and using some of the information in this record,
want to create a separate form for invoice, having the field "CompanyName"
fill in automatically. then from there, I am creating another form to enter
Serial Numbers, filling in three fields automatically, so I can just type in
the S/N, then hit the "New" button, enter another S/N, etc. How do I get the
fields from the first form, to fill in on the second form, and cascade that
information. The goal is to have a list of S/N's with invoice date for
warranty purposes.

I have hardly done anything with Access since taking a course 6 years ago,
so this is a challenge.
Thank you.
--
Tina L.
  #2  
Old January 14th, 2005, 01:14 AM
JP
external usenet poster
 
Posts: n/a
Default

Six years is a long time g

You say that you have a form for COMPANY and that you want to use "... some
of the information in this record ...". Does that mean that the form is
bound to some sort of table that stores the company information? If so,
then the easiest (or at least one of the easiest ways to do it) is the
following:

On the S/N form (assume it's called frmSN_form), have a field to hold the
company name (called it txbCompany for example). In the "OnCurrent" event
of the S/N form, specify an event procedure. Your code for the event
procedure will be a dlookup to the company name in the Company table that
puts the result in the txbCompany field.

Another way to do it is to pass the company name to the S/N form. This
approach works best if you are opening the S/N form from the Company form
(e.g., you have a command button on the Company form that opens the S/N
form). There are two ways to do this:

1. Create a property of the S/N form to hold the Company name and pass the
name to the property when you open the S/N form (you do this in code after
you've opened the S/N form but before you close the Company form)

2. Create a text box on the S/N form to hold the Company name. When you
open the S/N form, but before you close the Company form, put in a line of
code like this

forms!frmSN_form!txbCompany = me.txbCompany

(this assumes that the field with the company name is called txbCompany on
both the Company form and the S/N form)

Finally, if the Company form gets closed before the S/N form gets opened,
you can try this approach (it's not considered the most "elegant", but it
does work)

Go to modules and create a module. Define a GLOBAL variable called
gsCompany_Name. Before you close the Company form, have a line of code in
the form module that says something like gsCompany_Name = me.txbCompany.
Then put an "OnCurrent" event in the S/N form that says me.txbCompany =
gsCompany_Name.

This last approach stores the Company name in the global variable, and then
retrieves it from the global variable for each S/N record. Just be
careful -- it will retrieve it for EACH S/N record. If you have multiple
companies in this system, you could wind up screwing things up.

"Tina L." wrote in message
...
I have a form for COMPANY, and using some of the information in this

record,
want to create a separate form for invoice, having the field "CompanyName"
fill in automatically. then from there, I am creating another form to

enter
Serial Numbers, filling in three fields automatically, so I can just type

in
the S/N, then hit the "New" button, enter another S/N, etc. How do I get

the
fields from the first form, to fill in on the second form, and cascade

that
information. The goal is to have a list of S/N's with invoice date for
warranty purposes.

I have hardly done anything with Access since taking a course 6 years ago,
so this is a challenge.
Thank you.
--
Tina L.



  #3  
Old January 14th, 2005, 07:18 AM
Mike Painter
external usenet poster
 
Posts: n/a
Default

Tina L. wrote:
I have a form for COMPANY, and using some of the information in this
record, want to create a separate form for invoice, having the field
"CompanyName" fill in automatically. then from there, I am creating
another form to enter Serial Numbers, filling in three fields
automatically, so I can just type in the S/N, then hit the "New"
button, enter another S/N, etc. How do I get the fields from the
first form, to fill in on the second form, and cascade that
information. The goal is to have a list of S/N's with invoice date
for warranty purposes.

I have hardly done anything with Access since taking a course 6 years
ago, so this is a challenge.
Thank you.

The Northwind database has samples of what you want to do.

You should have a table that contains the invoice header information, who
it's sold to etc.
Another table holds detail information.
You would built a form for the header and a form for the detail and add the
latter to the former making a subform.

The invoice header table will contain a field for the company ID plus
whatever is needed.
Your header form would be based on a query joining the header table and the
company.
Filling in the companyID field for on the invoice header will automatically
fill in the rest of the company data.

Again the Northwind database has examples of this. For what you are
describing, if done properly with related tables
NO BUTTONS ARE NEEDED.
NO CODE IS NEEDED THAT ACCESS WILL NOT WRITE FOR YOU.

Be lazy and learn to use the power of a relational database. Less code is
better.




 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Record Update Michelle Using Forms 5 October 28th, 2004 07:59 AM
open a form through a subform in access 2000 Tammy Setting Up & Running Reports 12 October 22nd, 2004 02:43 PM
Automatically fill the fields on a form based on COMBO'S VALUE lin New Users 1 August 16th, 2004 11:55 PM
Automatically filling a field on a form bill anderson Using Forms 4 August 4th, 2004 04:28 PM


All times are GMT +1. The time now is 09:18 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.