Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Select query-problem when passing a control as a parameter


Message #1 by "Joseph Valdez" <e-valdez@a...> on Sun, 16 Mar 2003 20:02:02 -0800
I have a query that is derive from 3 other queries. In each of this query I
passed a parameter  Report_date. But because it does not look professional
with that approach - meaning everytime you want a resultset, you need to
type the date parameter, I decided to use a textbox with a date type so that
when the query runs , it should read this value.


In my query, for example "qryLocalTest", I passed the control
Forms!classx!txtinputdate in the Field criteria of the date field in my
table. I expect that when I click the button which is an option group based
on a Select Case statment, I should be able to preview th report.

Problem: Why is it prompting me to enter the parameter when in fact I have
that value in the textbox  already?
Here is part of my code

On Error GoTo ErrorPreview
Dim stDocName As String

Select Case [FrClassx]

    Case Is = 1
        DoCmd.OpenReport "Report 1", acViewPreview

    Case Is = 2
  '   DoCmd.OpenReport "Report2", acViewPreview    - I commented this out
but either way, same problem happen with code below

   stDocName = "qryByLocalTest"
   DoCmd.OpenQuery stDocName, acNormal, acEdit

I may be doing something wrong here. I know that with UPdates and deletes,
one can use the querydef and execute the parameters passed. Iwas successful
with it a couple of times,but with a Select statement, it does not allow
that approach. What is the best way to solve this problem?

This is another question to the Access gurus.

Thanks,

Joe



Message #2 by "Steve Klein" <Stephen@K...> on Mon, 17 Mar 2003 04:56:29 -0000
is the form still open when the report runs?  If the form has been shut,
access will have forgotten.

A simple test is to create an on open event of

msgbox Forms!classx!txtinputdate

and see what it delivers


Steve K


-----Original Message-----
From: Joseph Valdez [mailto:e-valdez@a...]
Sent: 17 March 2003 04:02
To: Access
Subject: [access] Select query-problem when passing a control as a
parameter


I have a query that is derive from 3 other queries. In each of this query I
passed a parameter  Report_date. But because it does not look professional
with that approach - meaning everytime you want a resultset, you need to
type the date parameter, I decided to use a textbox with a date type so that
when the query runs , it should read this value.


In my query, for example "qryLocalTest", I passed the control
Forms!classx!txtinputdate in the Field criteria of the date field in my
table. I expect that when I click the button which is an option group based
on a Select Case statment, I should be able to preview th report.

Problem: Why is it prompting me to enter the parameter when in fact I have
that value in the textbox  already?
Here is part of my code

On Error GoTo ErrorPreview
Dim stDocName As String

Select Case [FrClassx]

    Case Is = 1
        DoCmd.OpenReport "Report 1", acViewPreview

    Case Is = 2
  '   DoCmd.OpenReport "Report2", acViewPreview    - I commented this out
but either way, same problem happen with code below

   stDocName = "qryByLocalTest"
   DoCmd.OpenQuery stDocName, acNormal, acEdit

I may be doing something wrong here. I know that with UPdates and deletes,
one can use the querydef and execute the parameters passed. Iwas successful
with it a couple of times,but with a Select statement, it does not allow
that approach. What is the best way to solve this problem?

This is another question to the Access gurus.

Thanks,

Joe







  Return to Index