Re: Find record RunSQL in a crosstab query



What do you really want: the results displayed in the typical query result
format, or do you want to be able to programmatically use the values?

To create a temporary query that you can open, you can use:

Private Sub calschedule_Click()
Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef
Dim SQL As String

SQL = "SELECT * FROM qry_Crosstab_AM" & _
"WHERE [dateofyear] = FORMS!frm_qry_Crosstab_AM.calschedule"

Set dbCurr = CurrentDB()
Set qdfCurr = dbCurr.CreateQueryDef("qryTemp", SQL)
DoCmd.RunSQL "qryTemp"
dbCurr.QueryDefs.Delete "qryTemp"

End Sub

Remember, though, that all this will do, though, is display the results.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"LeParis" <LeParis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:37007ADF-A70C-46C6-9E76-A6C2A271D1C5@xxxxxxxxxxxxxxxx
> I am in a dead end here. How can I use The Openquery with this sql
statement?
>
> Thank you
> --
> LeParis
>
>
> "John Vinson" wrote:
>
> > On Thu, 10 Nov 2005 08:30:22 -0800, "LeParis"
> > <LeParis@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > >Here is the code:
> > >
> > >Private Sub calschedule_Click()
> > > Dim SQL As String
> > > SQL = "SELECT * FROM qry_Crosstab_AM" & _
> > > "WHERE [dateofyear] = FORMS!frm_qry_Crosstab_AM.calschedule"
> > > DoCmd.RunSQL SQL
> > >End Sub
> >
> > RunSQL is used for *action* queries - Update, Delete, Append and so
> > on. It isn't used for select queries like this.
> >
> > Try instead DoCmd.OpenQuery(SQL).
> >
> > John W. Vinson[MVP]
> >


.