add a query in a texte field in a form...

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Hi,
I 've got this query :

SELECT Sum([TEMPS].[DUREE]) AS SommeDeDUREE, [PROBLEMES].[TICKET]
FROM PROBLEMES INNER JOIN TEMPS ON [PROBLEMES].[NO]=[TEMPS].[NO]
GROUP BY [PROBLEMES].[TICKET]
HAVING ((PROBLEMES.TICKET)=TICKETno);

Where TICKETno is a parameter.

What I'd like to do, is to put the result in a text field, and tthat the
"TICKETno" take the actual number of another filed "ticket" in the same form
!
How the hell can I do this ?!

Thank you.
 
Fred,

Sorry, in my previous post I forgot to tell you you don't need the WHERE
clause in your query. The only reason why you need the query is to return a
single recordset containing the two fields wou need, in order to use the
DSum function on.
Whether you keep the grouping/Sum or not does not make any change at all as
far as the DSum function is concerned. If you need the grouping for another
purpose then keep it. Just keep in mind that in that case, if your query
returns many records, using DFirst instead of DSum (exactly the same syntax)
might improve performace.

Now, on the Syntax:

DSum("[DUREE]","r_temps"."[valTICKET]=" &
Formulaires![UTILISATEURS]![PROBLEMES
sous-formulaire].Formulaire![ctlDUREE])

To begin with, the domain and criterion parts should be separated by a
comma, not a period; if this is not just a typo in the posting, correct in
your macro.
Also, you had not mentioned that you are trying to pick up a value from a
control on a subform! Not sure I understand the reference to the control on
the subform in your statement, but something doesn't look right... I might
be wrong. The correct reference syntax is
Forms!FormName!SubFormName!ControlName
So, if I interpret the names in your expression correectly, then the sorrect
syntax should be:

DSum("[DUREE]","r_temps","[valTICKET]=" &
Formulaires![UTILISATEURS]![PROBLEMES sous-formulaire]![ctlDUREE])

Mind you, this is correct provided valTICKET is a numeric field! If it is
text, then it should be modified to:

DSum("[DUREE]","r_temps","[valTICKET]= ' " &
Formulaires![UTILISATEURS]![PROBLEMES sous-formulaire]![ctlDUREE] & " ' ")

HTH,
Nikos

Fred said:
I've made this :

DSum("[DUREE]","r_temps"."[valTICKET]=" &
Formulaires![UTILISATEURS]![PROBLEMES
sous-formulaire].Formulaire![ctlDUREE])


but it dosent work,
i cannot save my macro, or quit this window, with thatparametters..
wrong syntax ??

Thanks for your time !!!

In my query, I must add the SUM or not ?
because there is this DSUM here... ?!?!?
the I m in a sub form, calculating the value contained in another sub form
of this one..

Hope youunderstand me !!




"Nikos Yannacopoulos" <[email protected]> a écrit dans le message
de news:[email protected]...
Fred,

What do you mean "I 've got this query"? Is it a query saved under a name?
I'll assume that yes, and I'll assume its name is Total_Duration_Query (you
can change accordingly).

Now, you say you want to put the result in a text field on the form. I'll
assume the following names for the form and controls, and again you'll have
to change accordingly:
Form name: MyForm
TicketNo control: ctlTicket
TotalDuration Control: ctlDuree

Open the form in design view, select the control ctlTicket and open the
properties window. Select tab Events and place the cusrsor in the event
After Update. Clisk on the small button with the three dots that just
appeared on the right hand side of the cursor, and select Macro builder. You
will be taken to the macro design screen, and prompted for a name to save
the macro; give a meaningful name so you can understand what it's for later.
Now put the cursor in the Action column in the first line and type
"SetValue" (without the quotes). You will see a small window with cells for
two arguments at the bottom left hand corner. Argument: Type in:
Item ctlDuree
Expression: DSum("[DUREE]","Total_Duration_Query"."[TICKET]=" &
[Forms]![My_Form]![ctlTicket])

Remember to change the names to the actual ones! Save and close. Return to
the form and save. You should be finished.

HTH,
Nikos


Fred said:
Hi,
I 've got this query :

SELECT Sum([TEMPS].[DUREE]) AS SommeDeDUREE, [PROBLEMES].[TICKET]
FROM PROBLEMES INNER JOIN TEMPS ON [PROBLEMES].[NO]=[TEMPS].[NO]
GROUP BY [PROBLEMES].[TICKET]
HAVING ((PROBLEMES.TICKET)=TICKETno);

Where TICKETno is a parameter.

What I'd like to do, is to put the result in a text field, and tthat the
"TICKETno" take the actual number of another filed "ticket" in the
same
form
!
How the hell can I do this ?!

Thank you.
 
Back
Top