UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Allow Users To Select A Field In Query, Access 2016    
 
   
hqpham
post May 15 2019, 08:58 AM
Post#1



Posts: 7
Joined: 10-May 19



I have a table which have several fields and I want the user to be able to select which field (just one) to include a in make table query. Does anyone know how this can be achieved? I was thinking maybe a textbox promt. The user will know all the available fields to select.

Example:
Field4 Field5 Field6
001 002 002b
000 003 003b..and so on

Result: The user input Field5
Field5
xx
xxx



Go to the top of the page
 
theDBguy
post May 15 2019, 09:33 AM
Post#2


Access Wiki and Forums Moderator
Posts: 75,284
Joined: 19-June 07
From: SunnySandyEggo


Hi. You can use code to build the SQL statement and then execute it. Why would you need to create a new table every time?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
hqpham
post May 15 2019, 10:45 AM
Post#3



Posts: 7
Joined: 10-May 19



It does not have to be a make table query. The end result will be exported to an excel file.
Go to the top of the page
 
theDBguy
post May 15 2019, 10:49 AM
Post#4


Access Wiki and Forums Moderator
Posts: 75,284
Joined: 19-June 07
From: SunnySandyEggo


Then a select query should be fine. You can then export the query to Excel later. Just curious, how many fields are in the table and would the user always just select one of them?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
hqpham
post May 15 2019, 10:53 AM
Post#5



Posts: 7
Joined: 10-May 19



12 Fields to select from. Yes, the user will just need to select 1 field of out the 12 every time.

I prefer the user to select a field using a prompt/textbox instead of going into query to manually select a field.

Any help with this SQL statement will be greatly appreciated!
This post has been edited by hqpham: May 15 2019, 11:03 AM
Go to the top of the page
 
theDBguy
post May 15 2019, 11:09 AM
Post#6


Access Wiki and Forums Moderator
Posts: 75,284
Joined: 19-June 07
From: SunnySandyEggo


Hi. How about something like this instead?
1. You create 12 separate queries, one for each field in the table. For example, query1 would be like SELECT Field1 FROM Table, query 2 would be like SELECT Field2 FROM Table, and so on...
2. Create a form with a combobox, listbox, radio group, which ever you prefer, to list the 12 fields for the user to select one of them
3. Add a button to perform the action to export one of the 12 queries into Excel based on the whichever field the user selected from the list

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
hqpham
post May 15 2019, 12:25 PM
Post#7



Posts: 7
Joined: 10-May 19



I currently have 10 queries so creating an additional 12 queries for one process isn't my preference. Thanks for the idea though @theDBguy.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th May 2019 - 07:50 PM