Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query selection based on combo box

Status
Not open for further replies.

BGuidry

Technical User
Mar 18, 2009
28
US
I currently have a form that contains a command button, which runs a query (below).
Code:
Private Sub Command60_Click()
Dim qryLithLogLinks As Hyperlink
DoCmd.OpenQuery ("qryTrendChartLinks")
DoCmd.RunCommand acCmdOpenHyperlink
DoCmd.Close acQuery, "qryTrendChartLinks", acSaveNo
End Sub

The query selects the record, from a table, based on the selected item in a combo box on the same form that contains the command button (below).
Code:
SELECT tblTrendChartLinks.Trend_charts AS Expr1
FROM tblWell_ID INNER JOIN tblTrendChartLinks ON tblWell_ID.WELL_ID = tblTrendChartLinks.WELL_ID
WHERE (((tblWell_ID.WELL_ID)=[Forms]![frmWellMaintenance]![Combo34]))

But, I would prefer to have the command button open another form window, which contains a combo box, OK, and Cancel buttons. Then I would like the query to select the same record as the selected item from the combo box on the separate form window. This has worked well with the "On Click" event for reports, which then ran a macro (attached), which in turn opens the form containing a combo box, but cannot do the same with the query only.


 
OK, I got it now. I first had to set a command button to open the form dialog, and set the "OK" click button to open the query, with the query selecting the record equal to that selected in the dialog's combo box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top