Re: Msgbox if query no result displayed

From: Ken Snell [MVP] (kthsneisllis9_at_ncoomcastt.renaetl)
Date: 11/05/04


Date: Fri, 5 Nov 2004 09:01:18 -0500

You want the textbox on the main form to show a zero if there are no data in
the subform? Otherwise, it's a sum of that subform's column?

In the subform's footer, put a hidden textbox (name it txtSum) and use it to
sum the column. It's control source should be
    =Sum(Nz([NameOfSubformField],0))

In the main form's textbox, use a control source similar to this:
    =IIf(IsError([Subform].[Form].[txtSum]), 0, [Subform].[Form].[txtSum])

Subform is the name of the subform control (the control that holds the
subform).

-- 
        Ken Snell
<MS ACCESS MVP>
"MsgBoxIfNoData" <anonymous@discussions.microsoft.com> wrote in message
news:021801c4c304$ee009e80$a501280a@phx.gbl...
> As first, thank You for your kindness.
> I have Select Query based on table. The Query fills
> subform-Child. There are 2 columns in this subform.
> On the main form I have textbox with sum of second column
> in subform.
> In case that there is no data, I want to display msgbox to
> inform that sum/total of one column is 0 (currency).
> But, how should I express something like:
> If query result has no data, then sum of column is zero.
> I want to write code but how to express qery result?
>
> (sory about my english I'm trying)
>
> >-----Original Message-----
> >How are you "opening" the query? What is the use of the
> query:  form
> >recordsource? report recordsource? something else?
> >
> >To do what you want, you will have to use VBA code or
> macro to test whether
> >the query will return any records, or some other similar
> process. Post more
> >details, please, about what you're doing.
> >
> >-- 
> >
> >        Ken Snell
> ><MS ACCESS MVP>
> >
> >"MsgBoxIfNoData" <anonymous@discussions.microsoft.com>
> wrote in message
> >news:2f3d01c4c278$a3cbc100$a401280a@phx.gbl...
> >> Hi,
> >> I would like to display msgbox ("No data or no result")
> if
> >> my query don't find any data.
> >> How to write this code?
> >> I tried with If is null...but can't find any solution..
> >> Who will help me?
> >> Any help welcome.
> >> Thanx
> >
> >
> >.
> >


Relevant Pages

  • RE: Link a text box to combo boxes on a form.
    ... here is what I put in the Control Source section of the Textbox window in the ... Estimate being the field items I need displayed in the textbox (as a project ... Shell & Motiva being the query that contains the field mentioned above that ... Then create a subform based on the ProjectEstimate ...
    (microsoft.public.access.forms)
  • Re: is there a limit to how many records can be viewd in a subform
    ... I have a sample database that combines a textbox and combobox to allow you ... I am sorry, I misspoke, this is not a subform. ... the query and that line was line number 65535. ...
    (microsoft.public.access.forms)
  • Re: Alternative to group by
    ... I'm trying to have a query where it will ... display the sum of the quantities. ... and that the Form contains a textbox named txtItemID containing the ...
    (microsoft.public.access.queries)
  • Re: setting textbox value
    ... > For some reason I'm having troubles changing the text value of a textbox. ... the textbox equal to the results that come back from this query. ... control source looks something like the following: ... in a subform. ...
    (microsoft.public.access.formscoding)
  • RE: Link a text box to combo boxes on a form.
    ... You could try renaming the query. ... the subform approach should be straightforward. ... "mark" wrote: ... Estimate being the field items I need displayed in the textbox (as a project ...
    (microsoft.public.access.forms)