Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box help

Status
Not open for further replies.

newbie2181

Technical User
May 27, 2003
77
0
0
GB
Hi,

I have a table full my contacts. the tables creatively called contacts. What i want to be able to do is set up a drop down list where i can select one of my contacts from a drop down list then click a button pull up a invoice report with all the contacts details already entered into the invoice.

I have managed to set up the drop down list using a combo box and i have set up the button to open the invoice report i am having trouble working out how i would get the details of the contact selected into the invoice report? I imagine it would need some code in the on click event properties of the button?

Thanks a lot if you can help

Dan
 
You can link the textboxes on the form to the textboxes on the report.
Place a textbox on the report and set the controlSource to
[tt]
= Forms![YourFormName]![YourTextBoxNameOnTheForm]
[/tt]
What ever value there on the form will be reflected onthe report. Make sure your form is open when you open the report

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
cheers for the reply mate!

I just tried that, how does that link to what's selected in the drop down list?

Thanks mate

Dan
 
Here is an example of it. You can change the index[Column(0)] to get a different column. Index starts at 0(Zero)

Code:
Private Sub ComboBox1_AfterUpdate()
    Me.TextBox1.Value = Me.ComboBox1.Column(0)
End Sub


________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Thanks for your help mate but I can't seem to get that working?! It's definately me because i'm very new to access. I just want to make sure we are on the same level and i'll explain what i'm trying to acheive again.

I have a drop down list. The drop down list contains three fields from a record in a table contacts. The records are "company", "first name" and "last name". There are other fields in each record but i don't need to show all these in the drop down list. What i want to do is select say Dan from the drop down list then click a button called "invoice". The button then thinks right Dan was selected from the drop down list i'm going to go to the record take all the data for every field and populate all the text boxes i can on the report "invoice" with all the fields from the record in the table "contacts".

I don't know if that makes a little more sense??

Thanks a lot for your help and more importantly PATIENCE!! haha

Dan
 
There are two functions included in this.
[ul]
[li] After selecting the record from combobox show the ComapanyName, FirstName, LastName on form [/li]
Code:
Private Sub ComboBox1_AfterUpdate()
Me.TextBox1.Value = Me.ComboBox1.Column(0)
End Sub
You can even hide these textboxes. by setting "visible=false"

[li] Need some unbound controls on the report to set the data what we see on the form.[/li]
Place some textboxes on the report and set its controlsource to something like
Code:
= Forms![YourFormName]![YourTextBoxNameOnTheForm]
[/ul]
hope this helps

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Are you running a report on existing invoices or are you trying to create a new invoice? If it's existing invoices, I would think you might want a second combo box to display all existing invoices for that contact, and you would then run the invoice report for details of one invoice, or a different summary report to list all invoices (or within a date range?). Anyway, open the report setting the filter to only produce the report for invoices for the one contact:

Docmd.OpenReport "InvoiceList","[ContactID] = " me.cboContactID

(I'm assuming here that you have a numerical ID for each contact, but you could use a text value as long as you surround it with single quotes.)

On your report, first put a text box to contain the ContactID (I'll call it txtContactID). You may not want to display this value, so you could set visible property to No. Then put text box controls to display the name, address, etc, data about the contact. Populate these with the DLookup function for the data source. You can use the build function to build the function for each box, but it would look something like this:

DLookup("[address]","[Contacts]","ContactID] = " & me.txtContactID)

Note the quotes around each section of the function (other than the substitution of the value in me.txtContactID). The first section is the column you look up the value of (address in this example), the next is the table or query name, and the third is the where clause.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top