Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Run a query based on form combo box entry


Run a query based on form combo box entry

Author
Message
Barry
Barry
Forum God
Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)Forum God (2.3K reputation)

Group: Forum Members
Posts: 7, Visits: 27
I currently have a form that contains a command button, which runs a query (below). 
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). 

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, 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.

Barry

B&W Pantex

Edited
9/8/2009 by Barry
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search