Link to home
Start Free TrialLog in
Avatar of APD Toronto
APD TorontoFlag for Canada

asked on

Dropdowns in Queries

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
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

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

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.
Avatar of APD Toronto

ASKER

My goal is to end up with a tabular form that has combo boxes that user updates

Any quick wat to do this
SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

I figured out that I cannot do that with unbound controls, but yes I needed a continuous form.