🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.databases.ms-access
Article #46

Re: Q: MISC questions

#46
From: Karl Voit
Date: Fri, 31 Oct 1997 00:00
123 lines
4367 bytes


>> I've got an endless-form for my telephone-database:
>
>> room:  number of the room (1-4)
>> date:  date of the call
>> cost:  cost of the telephone-call
>> sum:   number of received impulses so far (1 pulse received -> +0.8 costs)
>> text:  -
>> sheet: number of the sheet, on which the call was noticed
>
>
>> Problem 1:
>> I want to calculate the cost by multiplying the difference of the sum by 0.8
>> e.g.: cost = ( sum - sum.old ) * 0.8
>> So, how do I refer to the sum.old-field?
>> Can I just enter the calculation or do I have to use a querry or so?
>
>You can include calculations or even function calls in your queries or
>as the ControlSource of your form and report controls. What is sum.old
>and where does it come from?

sum.old is the sum-field from one line above.

sum  cost
..   ...
4    3.2
6    1.6   =(6-4)*0.8

The only thing is - I think - how to refer to the line above.
I searched through the whole manual (paper & online) without getting
more than that Strg+"'" (Apostroph) gets the value of one line above.
But I can't imagine, how to use that in this case.




other Problem:

�> I've got another endless-form:
�
�> [...] some things that doesn't matter here
�> Sum: cost of a product
�> Zi1: Yes/No, if the room 1 is concerned
�> Zi2: Yes/No
�> Zi3: Yes/No
�> Zi4: Yes/No
�
�> I want to calculate the costs of room 1, 2, 3 or 4 and therefore, I have
�> to make a querry to get the number of rooms concerned of that line like:
�> Sum Zi1 Zi2 Zi3 Zi4  -> NrOfYes  -> CostForEachParty
�> 21  Y   Y   N   Y       3           (21/3=) 7
�> 30  N   Y   Y   N       2           (30/2=) 15
�
�Function SafeDivide(ByVal X As Double, ByVal Y As Double, ByVal Z As Variant)
�    If Abs(Y) > 0.0001 Then
�        SafeDivide = X / Y
�    Else
�        SafeDivide = Z
�    End If
�End Function
�
�select count(*) as [Sum], Zi1, Zi2, Zi3, Zi4,
�  SafeDivide(count(*), iif(Zi1 <> False, 1, 0) +
�  iif(Zi2 <> False, 1, 0) + iif(Zi3 <> False, 1, 0) +
�  iif(Zi4 <> False, 1, 0), Null) as CostForEachParty
�from Konto
�group by Zi1, Zi2, Zi3, Zi4


I call a macro when I go to the field (On Enter) perPerson (=CostsPerParty)
which executes this:

[perPerson] = SaveDiv([Sum], IIf([Zi1] = True, 1, 0) +
                             IIf([Zi2] = True, 1, 0) +
                             IIf([Zi3] = True, 1, 0) +
                             IIf([Zi4] = True, 1, 0), 0)

But when I go to that field in the form, there happenes nothing!
Not even 0 or an error.

So I tried it with the function-call diretcly: same effect.

Then I changed the macro-code to:

Me![perPerson]=33
or
[perPerson]=33
or
[perPerson]=[Sum]

...just to try it but: nothings happens EXCEPT:
When I use Me![perPerson], I get the errormessage:

*Reference not allowed* on field: 'Me'.
(Msg translated by me!)

Then I changed the OnEnter-event to Access Basic Code:
Me![perPerson]=33
-> same errormessage

And perPerson=33 doesn't do anything.
(btw, [perPerson]=33 is not allowed.)

Then I changed to OnGotFocus: same thing.



What's my mistake??????

I've got the feeling, that this is just one little thing that an outstanding
person can help me easily.


TNX again!


---
Karl VOIT alias vk@sbox.tu-graz.ac.at                     
         Student @ University of Technology of GRAZ (Austria)     
                                            (No, we have no Kangaroos!)     
Further information on http://www.sbox.tu-graz.ac.at/home/vk/
Technical Details
Message-ID: <63cmj8$ujh@fstgal00.tu-graz.ac.at>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <63612j$pf1$1@owl.slip.net> <637bqn$mj7@fstgal00.tu-graz.ac.at>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f67eb,17ab5fef9423dcf5
X-Google-Attributes: gidf67eb,public
X-Google-Thread: ff0ac,17ab5fef9423dcf5
X-Google-Attributes: gidff0ac,public
X-Google-Thread: 102b1d,17ab5fef9423dcf5
X-Google-Attributes: gid102b1d,public
X-Google-Thread: 1668c5,17ab5fef9423dcf5
X-Google-Attributes: gid1668c5,public
From: vk@sbox.tu-graz.ac.at (Karl Voit)
Subject: Re: Q: MISC questions
Date: 1997/10/31
Message-ID: <63cmj8$ujh@fstgal00.tu-graz.ac.at>
X-Deja-AN: 286173589
References: <63612j$pf1$1@owl.slip.net> <637bqn$mj7@fstgal00.tu-graz.ac.at>
Organization: Graz University of Technology, Austria
Newsgroups: comp.databases.ms-access,at.fido.msaccess,de.comp.datenbanken.ms-access,microsoft.public.de.access