Combo Box help please

D

Dermot

I have created........
A table of contacts "tblContactDetails"
A Query "qryContactDetails"
A Query qryParameterSurname
A Report "rptQueryParameterSurname2"
A form with a 2 column ( First / Last Name) combo box in it "cboCantactNames"

Questions
1. I can anyone advise me how I get a contacts details report to be
displayed when I click on a contacts name in the drop down list in the combo
box.

2. Do I need to use VBA to do this, can you post a "commented" example
please that I could examine.

3. Any other tips relevant would be appreciated

Thanks
 
K

KARL DEWEY

Build a query that uses the combo box as criteria --
[Forms]![YourFormName]![YourComboBox]

Use the query for record source for the report.

Build a macro that open the report.

In the property for the combo box - On Double Click put the macro. Open the
pull down and select the macro from the list.

Make your selection and then all you have to do is double click the combo
box to run the report.
 
A

Allen

Assuming your report's recordsource has the fields FirstName and
LastName, then these two lines of code should work:

If cboContactNames.ListIndex < 0 Then Exit Sub
DoCmd.OpenReport "rptQueryParameterSurname2", acViewPreview, ,
"FirstName=" & Chr(34) & cboContactNames.Column(0,
cboContactNames.ListIndex) & Chr(34) & " And LastName=" & Chr(34) &
cboContactNames.Column(0, cboContactNames.ListIndex) & Chr(34)

The last parameter of OpenReport contains the where clause, limiting
the report to show only the records that meet that condition. The
Chr(34) is the double quote character. Surrounding the names with
double quotes ensures that names with an apostrophe (like O'Neil) will
not cause an error.

For more examples in VBA code, see the tools at
http://www.aislebyaisle.com/access/tools3.htm
 
D

Dermot

Hi Karl,
Thanks for your reply.
I have tried what your suggested but don't get the results I expected.
Correct my error please.....
I built my query fro the record source (tblContacts)
In the "Surname Field" in the criteria field I entered
[Forms]![frmMyContacts]![combo7]
Created the open report macro and set the double click property as you
suggested.
What Happens now.......
A Enter Parameter Value Box opens with the text
"[Forms]![frmMyContacts]![combo7]" in it...........
exactly as it is typed.....I know this is wrong and must have entered the
criteria in the wrong place....can you explain what I might have done wrong?

I would like to include both the First and Second name Column to both
effect the relevant report to appear in the combo Box. (as I have several
contacts with the same surname)......not sure how I go about this either.

I hope I have explained my problem, well.
If you need further information let me know.
Thanks
Dermot





KARL DEWEY said:
Build a query that uses the combo box as criteria --
[Forms]![YourFormName]![YourComboBox]

Use the query for record source for the report.

Build a macro that open the report.

In the property for the combo box - On Double Click put the macro. Open the
pull down and select the macro from the list.

Make your selection and then all you have to do is double click the combo
box to run the report.

Dermot said:
I have created........
A table of contacts "tblContactDetails"
A Query "qryContactDetails"
A Query qryParameterSurname
A Report "rptQueryParameterSurname2"
A form with a 2 column ( First / Last Name) combo box in it "cboCantactNames"

Questions
1. I can anyone advise me how I get a contacts details report to be
displayed when I click on a contacts name in the drop down list in the combo
box.

2. Do I need to use VBA to do this, can you post a "commented" example
please that I could examine.

3. Any other tips relevant would be appreciated

Thanks
 
D

Dermot

Thanks for the reply Allen.
Thanks for the interesting link too.
Is the code you supplied for the combo box?

I am also interested to know where I went wrong In the posting above when I
tied to do what Karl explained to me?
Can you explain to me where I went wrong?
Thanks
Dermot
 

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

Similar Threads

Help Please Combo Box Used to Select a Report 6
Combo box 0
Combo or list box 0
Dependent combo box in Web Database 0
combo boxes 2
Text Field is Now Combo Box 2
Combo boxes in excel 6
Combo Box help please 4

Top