Column display with combo box

ootkhopdi

Registered User.
Local time
Tomorrow, 01:19
Joined
Oct 17, 2013
Messages
181
Sir

i have a table of 3 columns Named as C_Name, C_City and C_PIN

i have a combo box with All Value (All,C_Name,C_City and C_PIN)

i want to display All columns ,when i select All in Combo box and when i select Column C_Name, only display C_Name Column)
is it possible, if yes how
pls give me solution
 
Not sure that your terminology is correct.
You have a TABLE ? Maybe you wish to say a FORM.
 
yes i have table as above
and i want specific column in query/or in report
 
A possible solution here (attachment) but I think that is better to design as many reports as you need to open.
 

Attachments

There are a couple of ways to solve this problem and I use at least two of them regularly. One solution is to include an additional column in the query that concatenates the others.
So,
Select RecID, fld1 & " " & fld2 & " " & fld3 As VisibleField
Order by fld1, fld2, fld3;

This query produces 2 columns. The "key" column which will be hidden and the visible column which concatenates several other columns. Once you select an item, the visible column is what shows in the combo so as long as it is wide enough, you will always see all three columns instead of just seeing them in the list when you are selecting a value.

The second method is to modify the RecordSource query of the form to include a join to the lookup table where you can select additional columns. This join should probably be a right-join to allow for no matches. I use this method for example to show customer name and address from the customer table on an order form. One thing to watch out for if you use this method is to understand that the lookup fields will be updateable unless you lock them on the form. So, if you don't want the user to accidentally change the Customer Name or address in the customer table from the order form, the best solution is to set the Lock property of these lookup fields to Yes.
 
A possible solution here (attachment) but I think that is better to design as many reports as you need to open.
Thanks sir

yes i want same
but how can i do it
pls tell me step by step
thanks once again
 
Unfortunately this is easier to do than to explain.
So, I try to teach you how to learn from others.

Open the objects (tables, forms, queries, reports etc) in design view (and show, of course, the Property Sheet)
Do this in a logic order: tables first then queries then forms then reports
For each object look in each tab of the Property Sheet and see what settings are there.

Example:
- For Table1 is nothing to view. It is a very simple table that I use to test the program.
- Next (logic) I designated the form. So open this form in design view.
Again nothing new for the form itself.
- Select the combo
This time, under "Data" tab in the Property Sheet on the row named Row Source you see this: All;C_Name;C_City;C_Pin
Ask yourself what is this. You will quickly understand that this are rows in your combo.
Switch to "Event" tab. Again something new: On the row named On Click you will see: [Event Procedure] What is this ? Click the 3 dots at the end of the row and... voila ! here is defined how the program react when you click something in your combo: the program will open the report.
Now you think: Nothing new. I already know how to open a report. What I saw until now not explain how the report display one field or other one. So where is the code for this ? And the answer come itself: in the report.
So close the Visual Basic window, close the form and
- open the report in design view
Now take (again) a look to the Property Sheet.
Under the "Event" tab on the row On Activate something new: [Event Procedure]
Click the 3 dots and...
Ups ! Here is more code.
Try to understand what the code do. Next time you will know how to deal with a problem like this.
So:
First is a Select Case statement.
Do you know how this statement work ? If not, google until you have a good idea.
Then something become invisible ( Object.Visible = False)
Then some objects are moved. How ? Google and understand what is the .Left property.

And so on.

After you understand my code you should take a look and try what Pat suggest.
Of course that you will have more question. But either Pat either me or others will give you the answers that will help you to move a step forward.

Good luck !
 

Users who are viewing this thread

Back
Top Bottom