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
Solved

Dropdowns in Queries

Posted on 2013-10-23
7
157 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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 84
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 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 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 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