Select query problems Access 2003

  • Thread starter Thread starter Neville MADDEN
  • Start date Start date
N

Neville MADDEN

Good morning everybody

I'm using Access2003 on Windows XP SR2

I want to run a select query using parameters to query a table of placenames
and details. All pretty straightforward.

When I try a click event using the selection of a combo or listbox to set the
criteria in the query { Forms![frmSearch]![cboName] } the query gives a
nil return

nothing happens....the form opens but doesn't display any results.

But when is use a txtBox and manually enter known data and run a command
button everything works as it should

This is the code for the cmd button.



Private Sub cmdSearch_Click()
'Run query and send results to to form

DoCmd.OpenForm "frmPlaceNames", , , , , , "qryMapSearch"
End Sub

Can anyone help me as to why the click event on the listbox doesn't want to
work.

This is the code for the listbox click event

Private Sub lstMap_DblClick(Cancel As Integer)
DoCmd.OpenQuery "qryMapSearch"
DoCmd.OpenForm "frmPlaceNames", , , , , , "qryMapSearch"
End Sub

and the criteria in the query is simply Forms![frmSearch]![cboName]

Neville
Cootamundra NSW
Australia
 
The syntax you probably want is
Docmd.OpenForm "FrmPlaceNames", ,"qryMapSearch"

I assume that you want to tell the form to use qryMapSearch as the form's
record source.

Private Sub cmdSearch_Click()
'Run query and send results to to form

DoCmd.OpenForm "frmPlaceNames", , "qryMapSearch"
End Sub

By the way the form will use the query. There is no reason to open the query
separately.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top