Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dropdowns in Queries

Posted on 2013-10-23
7
Medium Priority
?
163 Views
Last Modified: 2013-10-23
Hello Experts,

I am trying to build a MS Access query that I want to present to the user as a subform that they will edit, but when I run the query, I don't know how to get all of the users to show up from the tblUsers in a dropdown?

Here is what my query looks like so far:

SELECT [tblUsers].[fldFName] & " " & Left([tblUsers].[fldLName],1) & "." AS [User], tblReservations.fldUserInit AS ['User Initials'], tblReservations.fldReservID
FROM tblReservations INNER JOIN tblUsers ON tblReservations.fldUser = tblUsers.fldUserID
WHERE (((tblReservations.fldTripSubType)=[Forms]![frmDiscrepDetails]![txtTripID]));

Open in new window


Thank you
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 48

Expert Comment

by:Dale Fye
ID: 39595129
There is no way to implement that within the query itself (having a parameter popup that involves a combo box instead of a simple textbox).

However, if you are going to use that query in a report, you could use the reports Open event to popup a form, allow the user to make a selection from the combo box on that form, then refer to that form in the query.

When I do this, I put Cancel and Select buttons on the form.  When the user selects either of these buttons, it updates the Tag property of the form to either "Cancel" or "Select", and then hides the form.  When this happens, the rest of the code in the Report_Open event continues.

If the user selects Cancel, I set the Cancel parameter of the Report_Open event to true.  If the user clicks the "Continue", then the report opens and uses the parameter in that form for the query.

Finally, the Report_Close event closes the popup form.  This does not provide quite the same functionality as you have described, but it works for reports.

Private Sub Report_Open(Cancel As Integer)

    DoCmd.OpenForm "myPopup", , , , , acDialog
    
    If Forms("myPopup").Tag = "Cancel" Then
        Cancel = True
    Else
        Cancel = False
    End If
        
End Sub

Private Sub Report_Close()

    If CurrentProject.AllForms("myPopup").IsLoaded Then
        DoCmd.Close acForm, "myPopup"
    End If
    
End Sub

Open in new window

0
 
LVL 85
ID: 39595150
subform that they will edit, but when I run the query,
As fyed mentions, you can't do this in a query, but if you're using this to bind to a subform, then you can just add the Combo to the subform and use that. You can then setup the combo as needed, and your users will be able to select an item from the dropdown.
0
 

Author Comment

by:APD_Toronto
ID: 39595263
My goal is to end up with a tabular form that has combo boxes that user updates

Any quick wat to do this
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 1000 total points
ID: 39595396
If you want to use multiple combo boxes to filter the form, your best method would be to include those in the header or footer of the form.  I usually include a "Filter/Clear Filter" button that will analyze the values of the various combo boxes and build a filter string that is applied to the forms Filter property, rather than trying to change the WHERE clause of the query that is the recordsource of the form.

In the Click Event, of the "Filter" button, I assess which of the combo boxes has a non-null value and build the string by stepping through the combo boxes.
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 39595692
that user updates
What is the intent of this form?

Are you trying to filter data?

Or are you trying to allow the users to edit data?

If you're filtering, then the methods suggested by fyed (i.e. add the combos to the Header) would be the best way to achieve this.

If you're editing data, and if your intent is to allow the users to use the combos to update/add data in the form, then the combos typically would need to be in the form's Detail section. In most cases, instead of a Datasheet form you'd have to use a Continuous form and build it to do what you want.
0
 

Author Comment

by:APD_Toronto
ID: 39595728
Yes I am trying to allow the user to edit data. I don't need to filter.

I am now using a continuous form, but I need to edit 1 field by code as shown below, but all my rows get the same value with this code.

txtConf = fldUser.Column(2, fldUser.ListIndex) & " " & fldReservID

Open in new window

0
 

Author Closing Comment

by:APD_Toronto
ID: 39595925
I figured out that I cannot do that with unbound controls, but yes I needed a continuous form.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question