Solved

Dropdowns in Queries

Posted on 2013-10-23
7
155 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now