Opening form from form with information filled in

L

Lisa

I have a form 'Customers' that contains data such as CustomerID,
billing information, shipping information, etc...
I would like to put a command button on that form that would open up
the form 'Orders'
I know what I am doing up until that point.
What I would like to happen is for the 'Order' form to open with the
appropriate fields filled in from the 'Customer' form.
Is there a way to do something like this?
Thanks for any help and support. I really appreciate the time that
those who are so knowledgeable give to those of us who are learning!
 
J

John Vinson

I have a form 'Customers' that contains data such as CustomerID,
billing information, shipping information, etc...
I would like to put a command button on that form that would open up
the form 'Orders'
I know what I am doing up until that point.
What I would like to happen is for the 'Order' form to open with the
appropriate fields filled in from the 'Customer' form.
Is there a way to do something like this?
Thanks for any help and support. I really appreciate the time that
those who are so knowledgeable give to those of us who are learning!

What are "the appropriate fields"? The ONLY field that should be
stored in the Order table is the CustomerID; if you're trying to store
the customer name and address redundantly - don't.

The most common way to do this is to use a Combo Box on the Orders
form to select the customer; you can *display* (without storing) the
customer information by including the fields you want shown in the
Combo Box's rowsource query. Put textboxes on the Order form with
control sources

=cboCustomerID.Column(n)

where cboCustomerID is the name of the combo box, and(n) is the zero
based subscript of the desired field (use (2) to show the third field
in the query for example).

John W. Vinson[MVP]
 
L

Lisa

By appropriate fields I meant CustomerID, Customer Name and Company
Name. I have the order form set up so that the header displays Customer
Name and Company Name. This is filled in when a Orders.CustomerID (from
an Orders qry) is selected from a combo box.
What I had hoped to do was to create a command button that when clicked
would open the Orders Form with the Orders.CustomerID filled in. That
in turn would fill in the Customer Name and Company Name.
It is easy to locate a CustomerID if there aren't many customers.
However, as business increases that would be a long list.
Also, many CustomerID numbers are quite long - generated from an
on-line merchant program. To manually enter them on the order form
after they have already been entered on the customer form is asking for
typographical errors.
I am trying to put the db together for a friend who opened a home-based
business. I may be a little over my head.
Thanks again for any help.
 
J

John Vinson

By appropriate fields I meant CustomerID, Customer Name and Company
Name. I have the order form set up so that the header displays Customer
Name and Company Name. This is filled in when a Orders.CustomerID (from
an Orders qry) is selected from a combo box.
What I had hoped to do was to create a command button that when clicked
would open the Orders Form with the Orders.CustomerID filled in. That
in turn would fill in the Customer Name and Company Name.

Just don't STORE the Customer Name or the Company Name in the Orders
table!
It is easy to locate a CustomerID if there aren't many customers.
However, as business increases that would be a long list.

Well... you don't need to scroll down the list. Combo Boxes have a
very nice Autocomplete feature. And don't you still HAVE that problem,
if you're going to need to search for a customer on the Customer form?
But see below.
Also, many CustomerID numbers are quite long - generated from an
on-line merchant program. To manually enter them on the order form
after they have already been entered on the customer form is asking for
typographical errors.

I would suggest that - unless there is no other way to identify a
customer - that the user never type a CustomerID at all; can the combo
display the company or customer NAME, and store the ID?
I am trying to put the db together for a friend who opened a home-based
business. I may be a little over my head.
Thanks again for any help.

What you can do (and what I should have posted before, sorry I got
rushed) is put some VBA code in the Clickevent of the button which
opens the Order form. Simplest is to pass the form's current
CustomerID in the OpenArgs argument:

DoCmd.OpenForm strDocument, <yadda yadda>, OpenArgs:=Me!CustomerID

Then in the Order form's Open event put code like

Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then ' it was called from the customer form
Me!cboCustomerID.DefaultValue = Me.OpenArgs
End If
End Sub


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top