?
Solved

Dropdowns in Queries

Posted on 2013-10-23
7
Medium Priority
?
161 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Suggested Courses

771 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