[AccessD] When a query refers to a control on a form which isnot open - how to supply a default?

David McAfee davidmcafee at gmail.com
Wed Jun 2 13:09:28 CDT 2010


Let me think out of the box for a bit.

Where is this query being called from?

Usually when I call a query that refers to a form, it is called from
the form being referred to.

If this is the case, you can check if the if the field is blank before
you call the query.

something like

if nz(me.RecordID,0) = 0 then
     'Call query or report without the reference to this form
Else
     'call existing query which references this form
end if



On Wed, Jun 2, 2010 at 10:47 AM, Bill Benson (vbacreations)
<vbacreations at gmail.com> wrote:
> Doug, not sure how to implement this? The query is "out there" as an object
> in the database; it is used as a recordsource for a subform ... how am I
> supposed to let code control it? I am not using any code?
>
> On the other hand if what you mean is that I should set a parameter equal to
> a function which code I have controlled - well that is the same thing as
> others are suggesting.
>
> My choice appears to be VBA or VBA or VBA ... rather than VBA or more
> flexible SQL...?
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Doug Steele
> Sent: Wednesday, June 02, 2010 10:11 AM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] When a query refers to a control on a form which
> isnot open - how to supply a default?
>
> Change the query to a parameter query; then your code controls the value
> that is passed to the query.
>
> Doug
>
> On Tue, Jun 1, 2010 at 3:43 PM, Bill Benson (vbacreations) <
> vbacreations at gmail.com> wrote:
>
>> SELECT TblCIB.RecordID, TblCIB.ShopOrder, TblCIB.ItemNumber FROM TblCIB
>> WHERE (((TblCIB.RecordID)=[Forms]![frmExciterIndividualEntry]![RecordID]))
>>
>> The above sql is causing the user to be prompted for a value of
>> [Forms]![frmExciterIndividualEntry]![RecordID] when that form is not open
>> and/or the control not populated. I would like that when there is no form
>> or
>> control available at runtime, the query just assumes a 0 or "" [default]
> so
>> that my users are not prompted. Is there some simple [single expression]
>> way
>> to do this short of the workaround I show below, which seems like
>> overkill??
>>
>>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.819 / Virus Database: 271.1.1/2912 - Release Date: 06/02/10
> 02:25:00
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



More information about the AccessD mailing list