Printing forms

conjoa

New member
Local time
Today, 01:05
Joined
Nov 18, 2007
Messages
7
Dear Reader

Is there any possible way, only to print out the record shown with in the form. The case I am interested in, is a customer/order form. at the top, it shows the customers name (selected by user from a lookup table (combo box)), and below it shows the order details i.e items, quantity ordered, discount and total price. I want to be able to print out the information in this form. Is there anyway?

Also if possible, is their anyway, to be able to select a customers last name from a lookup table (combo box), and then to get the remainder of the information inserted into the form automatically, i.e. can the customers address, and telephone number be shown automatically?

CJM
 
The last first: Copy data from ComboBox to fields in your form.

With the form in design view, right click the combo/list box and select
Build Event, then Code Builder.

Select BeforeUpdate from the top right corner.

Enter the following code between the 2 existing lines.

Private Sub Combo55_BeforeUpdate(Cancel As Integer)

[fieldname] = ([Combo55],#)

End Sub

The [fieldname] is the name of the field you want to copy the data to.
Combo55 is the number of the combo box you're using.
The # refers to the column in the combo box. The columns start with number 0 (zero) in the left most column and increases by 1 for each column you move to the right. The third column from the left would therefore be column 2.

Each column you wish to copy when you select a record in the combo box needs its own line of code.

When you created the combo box using the wizard, you had the option of saving one of the columns into a field at that time. If you did this, you don't have to use the code to save that column, it’s already done.
 
Thankyou Statsman for your speedy replie!!!

I was wondering if you could explain it again, because I tried doing it, but it did not workout. I most probably made a mistake in the coding, seeing as I have never done any before, and i have no idea as to how to do it.

If you could simplfy the above, it would be of great help!!

Thanking you

CJM
 
Sorry for the delay.

The code must go in the Before Update section of the form properties.

If you created the combo box using the combo box wizard, you had the option of copying one column from the combo box to the form. If you did that, that column is already done.
Any other columns you wish to copy to a field on the form must be done one at a time in code.

So, if you had a customer name and billing address in the combo box (for example) with the customername as column 0 and the address as column 1 in a Combo box that was Combo 55 you would enter:
[customername]=([Combo55],0)
[billingaddress]=(Combo55],1)

and so on for each column in the combo box you wish to copy to your form.
 

Users who are viewing this thread

Back
Top Bottom