Problem with form activate event

G

Guest

Hi

I have the below Form_activate event running in a orderform.
From the orderform I open a payment form..when done I close the payment form
and the orderform activates again..running the below to set the paymentstatus
of the current order. It works fine...however when opening the orderform for
the first time something odd happens in the first record..without having
"activating" the form just opened it...it sets the status to 12..only the
first record being current..

Anyone know what is wrong about this...

Thank you in advance

Mattias


Private Sub Form_Activate()
Me.Recalc
If (Me!Total2 = Me!Total) Then
Me!Status = 13
End If
If (Me!Total2 < Me!Total) Then
Me!Status = 12
End If
If (IsNull(Me!Total2)) Then
Me!Status = 10
End If
End Sub
 
R

Rob Oldfield

I'm not sure exactly what you mean.... the activate event _is_ fired by
opening a form - from help:

"When you first open a form, the following events occur in this order:
Open Þ Load Þ Resize Þ Activate Þ Current"

You could drop a breakpoint into your routine and check to see what it
thinks 'Me' is. It also seems to me that your logic is a bit out... if you
have something that you want to do when the payment form closes, then why
not attach it to that close event?
 
G

Guest

Hi

Cannot have it on the payment form close as it is not a unique
payment...every order can have sevaral payments linked via the
orderno(invoiceno.). So the of the order can be paid in full, not paid,
partly paid etc etc.

Just tried to comment the me.recalc line and the odd behavior when opening
the form dissapered..but on the other hand the activate event did not set
the paymentstatus at all anymore!?

Mattias
 
R

Rob Oldfield

I still don't get what it is that you're trying to achieve. What are the
total fields? Do they depend upon data entered into the payment form? Do
they depend upon other entries entered previously onto the payments table
(whether via the payments form or not)? What is the me.recalc supposed to
do?
 
G

Guest

Hi Rob

Total is the order sum to be paid and total2 = Paid up to now. They are both
calculated fields (currency) in the form.
I have a hidden subform showing and summing all payments ..it is from this
subform where total2 get its value.

I want to set the paymentstatus at once after having added a payment to the
current record.

Mattias
 
R

Rob Oldfield

Hmmm. I don't see why you need the hidden subform, and it might well be
that that's is the thing causing you problems. Me.Recalc isn't going to
update anything if it depends upon code running via another form. Two
ideas...

You could just base the Order form on a query that does the calculation...
group by all the Order fields, and sum the amounts from the Payment
fields... if you do that then a requery (in the close event of the payment
form) is going to work. (Although it'll make all the fields read-only and
the requery will take you back to the first record)

Second way (and the one that I think I'd go for) would be just to drop
something like this into the close event of the payment form...

dim tot2 as whatever
tot2=dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid))
forms!orders!tot2=tot2
if forms!orders!total>tot2 then
forms!orders!status="Set lawyers on to customer"
elseif forms!orders!total<tot2
forms!orders!status="Pocket the spare cash"
..
..
end if
 
G

Guest

Hi Rob

Sorry for this late reply and thank you for your suggestion.
There is no code in the subform only a txt control in the subforms footer
summing the payments.

So total2 (paid up to now only has as its
recordsource:=PaymentsSub!SubtotalAmount)

I tried your second suggestion in the paymentforms close event. Somehow it
does not update the order first time I close it....need to open payment form
a second time and close then it has updated the orderpaymentstatus.

What can be wrong here.

Mattias

Rob Oldfield said:
Hmmm. I don't see why you need the hidden subform, and it might well be
that that's is the thing causing you problems. Me.Recalc isn't going to
update anything if it depends upon code running via another form. Two
ideas...

You could just base the Order form on a query that does the calculation...
group by all the Order fields, and sum the amounts from the Payment
fields... if you do that then a requery (in the close event of the payment
form) is going to work. (Although it'll make all the fields read-only and
the requery will take you back to the first record)

Second way (and the one that I think I'd go for) would be just to drop
something like this into the close event of the payment form...

dim tot2 as whatever
tot2=dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid))
forms!orders!tot2=tot2
if forms!orders!total>tot2 then
forms!orders!status="Set lawyers on to customer"
elseif forms!orders!total<tot2
forms!orders!status="Pocket the spare cash"
..
..
end if


Mattias said:
Hi Rob

Total is the order sum to be paid and total2 = Paid up to now. They are both
calculated fields (currency) in the form.
I have a hidden subform showing and summing all payments ..it is from this
subform where total2 get its value.

I want to set the paymentstatus at once after having added a payment to the
current record.

Mattias
 
R

Rob Oldfield

I'd guess that your original method was failing because the recalc wasn't
updating the subform correctly (requerying would be more likely to work),
but I still prefer the second way.

If you add a breakpoint into the code for the payments form, then can you
see the correct figure being calculated the first time the form closes? It
should work without any need to refresh the display.


Mattias said:
Hi Rob

Sorry for this late reply and thank you for your suggestion.
There is no code in the subform only a txt control in the subforms footer
summing the payments.

So total2 (paid up to now only has as its
recordsource:=PaymentsSub!SubtotalAmount)

I tried your second suggestion in the paymentforms close event. Somehow it
does not update the order first time I close it....need to open payment form
a second time and close then it has updated the orderpaymentstatus.

What can be wrong here.

Mattias

Rob Oldfield said:
Hmmm. I don't see why you need the hidden subform, and it might well be
that that's is the thing causing you problems. Me.Recalc isn't going to
update anything if it depends upon code running via another form. Two
ideas...

You could just base the Order form on a query that does the calculation...
group by all the Order fields, and sum the amounts from the Payment
fields... if you do that then a requery (in the close event of the payment
form) is going to work. (Although it'll make all the fields read-only and
the requery will take you back to the first record)

Second way (and the one that I think I'd go for) would be just to drop
something like this into the close event of the payment form...

dim tot2 as whatever
tot2=dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid))
forms!orders!tot2=tot2
if forms!orders!total>tot2 then
forms!orders!status="Set lawyers on to customer"
elseif forms!orders!total<tot2
forms!orders!status="Pocket the spare cash"
..
..
end if


Mattias said:
Hi Rob

Total is the order sum to be paid and total2 = Paid up to now. They
are
both
calculated fields (currency) in the form.
I have a hidden subform showing and summing all payments ..it is from this
subform where total2 get its value.

I want to set the paymentstatus at once after having added a payment
to
the
current record.

Mattias
:

I still don't get what it is that you're trying to achieve. What
are
the
total fields? Do they depend upon data entered into the payment
form?
Do
they depend upon other entries entered previously onto the payments table
(whether via the payments form or not)? What is the me.recalc
supposed
to
do?


Hi

Cannot have it on the payment form close as it is not a unique
payment...every order can have sevaral payments linked via the
orderno(invoiceno.). So the of the order can be paid in full, not paid,
partly paid etc etc.

Just tried to comment the me.recalc line and the odd behavior when opening
the form dissapered..but on the other hand the activate event did
not
set
the paymentstatus at all anymore!?

Mattias

:

I'm not sure exactly what you mean.... the activate event _is_
fired
by
opening a form - from help:

"When you first open a form, the following events occur in this order:
Open Þ Load Þ Resize Þ Activate Þ Current"

You could drop a breakpoint into your routine and check to see
what
it
thinks 'Me' is. It also seems to me that your logic is a bit
out...
if
you
have something that you want to do when the payment form closes, then
why
not attach it to that close event?



Hi

I have the below Form_activate event running in a orderform.
From the orderform I open a payment form..when done I close the
payment
form
and the orderform activates again..running the below to set the
paymentstatus
of the current order. It works fine...however when opening the
orderform
for
the first time something odd happens in the first record..without
having
"activating" the form just opened it...it sets the status to 12..only
the
first record being current..

Anyone know what is wrong about this...

Thank you in advance

Mattias


Private Sub Form_Activate()
Me.Recalc
If (Me!Total2 = Me!Total) Then
Me!Status = 13
End If
If (Me!Total2 < Me!Total) Then
Me!Status = 12
End If
If (IsNull(Me!Total2)) Then
Me!Status = 10
End If
End Sub
 
G

Guest

Hi Rob

I do need this subform in the order form.
Right now I have the below in the paymentform
with this code I need to open and close the paymentform a second time to
make it enter the statusno in the orderform

Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long

If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub

Based on this ..do you know what to do now.


Rob Oldfield said:
I'd guess that your original method was failing because the recalc wasn't
updating the subform correctly (requerying would be more likely to work),
but I still prefer the second way.

If you add a breakpoint into the code for the payments form, then can you
see the correct figure being calculated the first time the form closes? It
should work without any need to refresh the display.


Mattias said:
Hi Rob

Sorry for this late reply and thank you for your suggestion.
There is no code in the subform only a txt control in the subforms footer
summing the payments.

So total2 (paid up to now only has as its
recordsource:=PaymentsSub!SubtotalAmount)

I tried your second suggestion in the paymentforms close event. Somehow it
does not update the order first time I close it....need to open payment form
a second time and close then it has updated the orderpaymentstatus.

What can be wrong here.

Mattias

Rob Oldfield said:
Hmmm. I don't see why you need the hidden subform, and it might well be
that that's is the thing causing you problems. Me.Recalc isn't going to
update anything if it depends upon code running via another form. Two
ideas...

You could just base the Order form on a query that does the calculation...
group by all the Order fields, and sum the amounts from the Payment
fields... if you do that then a requery (in the close event of the payment
form) is going to work. (Although it'll make all the fields read-only and
the requery will take you back to the first record)

Second way (and the one that I think I'd go for) would be just to drop
something like this into the close event of the payment form...

dim tot2 as whatever
tot2=dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid))
forms!orders!tot2=tot2
if forms!orders!total>tot2 then
forms!orders!status="Set lawyers on to customer"
elseif forms!orders!total<tot2
forms!orders!status="Pocket the spare cash"
..
..
end if



Hi Rob

Total is the order sum to be paid and total2 = Paid up to now. They are
both
calculated fields (currency) in the form.
I have a hidden subform showing and summing all payments ..it is from this
subform where total2 get its value.

I want to set the paymentstatus at once after having added a payment to
the
current record.

Mattias
:

I still don't get what it is that you're trying to achieve. What are
the
total fields? Do they depend upon data entered into the payment form?
Do
they depend upon other entries entered previously onto the payments
table
(whether via the payments form or not)? What is the me.recalc supposed
to
do?


Hi

Cannot have it on the payment form close as it is not a unique
payment...every order can have sevaral payments linked via the
orderno(invoiceno.). So the of the order can be paid in full, not
paid,
partly paid etc etc.

Just tried to comment the me.recalc line and the odd behavior when
opening
the form dissapered..but on the other hand the activate event did not
set
the paymentstatus at all anymore!?

Mattias

:

I'm not sure exactly what you mean.... the activate event _is_ fired
by
opening a form - from help:

"When you first open a form, the following events occur in this
order:
Open Þ Load Þ Resize Þ Activate Þ Current"

You could drop a breakpoint into your routine and check to see what
it
thinks 'Me' is. It also seems to me that your logic is a bit out...
if
you
have something that you want to do when the payment form closes,
then
why
not attach it to that close event?



Hi

I have the below Form_activate event running in a orderform.
From the orderform I open a payment form..when done I close the
payment
form
and the orderform activates again..running the below to set the
paymentstatus
of the current order. It works fine...however when opening the
orderform
for
the first time something odd happens in the first record..without
having
"activating" the form just opened it...it sets the status to
12..only
the
first record being current..

Anyone know what is wrong about this...

Thank you in advance

Mattias


Private Sub Form_Activate()
Me.Recalc
If (Me!Total2 = Me!Total) Then
Me!Status = 13
End If
If (Me!Total2 < Me!Total) Then
Me!Status = 12
End If
If (IsNull(Me!Total2)) Then
Me!Status = 10
End If
End Sub
 
R

Rob Oldfield

Couple of things....

Why do you think you need the subform? (....that's assuming that the one
that you're talking about is the same one that I'm thinking about... the
hidden one?)

The subform won't do anything in the code you're attached because it's not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way you're
linking the data entered on the payments form back to the original order.
What code are you using to open that? (i.e. how does the payment form know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is producing when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
G

Guest

Hi again.

I removed the subform now!! Tried your original idea to sum the payments in
the paymentform close event. But to make it work completly I had to ad sum
creditcardfee and curryency exchange fee. I also added a nz to be albe to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go to the next
record and back again...the only value being saved and still correct is the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and CurrencyExchangefee to
the ordertable and the form controls bound to the new fields. It saves the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub
 
R

Rob Oldfield

Hmmm. Can't see how that's not working. Try stepping through the code....
if you're setting Total2 to 10, for example, and Total is 20... then it must
work.

(Just in case you don't know how.... put the cursor on the If
Forms!Order!Total2 =Forms!Order!Total Then line... hit F9 to toggle a
breakpoint.... go through attempting to use the code and it will stop at
that line... hit F8 to move to the next line.... or F5 to carry on as usual)

Where does it go? Does it get to the Forms!Order!Status = 13 line?


Mattias said:
Hi again.

I removed the subform now!! Tried your original idea to sum the payments in
the paymentform close event. But to make it work completly I had to ad sum
creditcardfee and curryency exchange fee. I also added a nz to be albe to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go to the next
record and back again...the only value being saved and still correct is the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and CurrencyExchangefee to
the ordertable and the form controls bound to the new fields. It saves the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub



Rob Oldfield said:
Couple of things....

Why do you think you need the subform? (....that's assuming that the one
that you're talking about is the same one that I'm thinking about... the
hidden one?)

The subform won't do anything in the code you're attached because it's not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way you're
linking the data entered on the payments form back to the original order.
What code are you using to open that? (i.e. how does the payment form know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is producing when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
G

Guest

Hi Rob

Did you mean I should run the code bound or unbound case?

Rob Oldfield said:
Hmmm. Can't see how that's not working. Try stepping through the code....
if you're setting Total2 to 10, for example, and Total is 20... then it must
work.

(Just in case you don't know how.... put the cursor on the If
Forms!Order!Total2 =Forms!Order!Total Then line... hit F9 to toggle a
breakpoint.... go through attempting to use the code and it will stop at
that line... hit F8 to move to the next line.... or F5 to carry on as usual)

Where does it go? Does it get to the Forms!Order!Status = 13 line?


Mattias said:
Hi again.

I removed the subform now!! Tried your original idea to sum the payments in
the paymentform close event. But to make it work completly I had to ad sum
creditcardfee and curryency exchange fee. I also added a nz to be albe to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go to the next
record and back again...the only value being saved and still correct is the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and CurrencyExchangefee to
the ordertable and the form controls bound to the new fields. It saves the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub



Rob Oldfield said:
Couple of things....

Why do you think you need the subform? (....that's assuming that the one
that you're talking about is the same one that I'm thinking about... the
hidden one?)

The subform won't do anything in the code you're attached because it's not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way you're
linking the data entered on the payments form back to the original order.
What code are you using to open that? (i.e. how does the payment form know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is producing when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
G

Guest

Rob

Tried the bound one. It did run throw the code all the way. The one I want
set to 13 had the value 10 but did not change it....

Mattias

Rob Oldfield said:
Hmmm. Can't see how that's not working. Try stepping through the code....
if you're setting Total2 to 10, for example, and Total is 20... then it must
work.

(Just in case you don't know how.... put the cursor on the If
Forms!Order!Total2 =Forms!Order!Total Then line... hit F9 to toggle a
breakpoint.... go through attempting to use the code and it will stop at
that line... hit F8 to move to the next line.... or F5 to carry on as usual)

Where does it go? Does it get to the Forms!Order!Status = 13 line?


Mattias said:
Hi again.

I removed the subform now!! Tried your original idea to sum the payments in
the paymentform close event. But to make it work completly I had to ad sum
creditcardfee and curryency exchange fee. I also added a nz to be albe to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go to the next
record and back again...the only value being saved and still correct is the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and CurrencyExchangefee to
the ordertable and the form controls bound to the new fields. It saves the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub



Rob Oldfield said:
Couple of things....

Why do you think you need the subform? (....that's assuming that the one
that you're talking about is the same one that I'm thinking about... the
hidden one?)

The subform won't do anything in the code you're attached because it's not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way you're
linking the data entered on the payments form back to the original order.
What code are you using to open that? (i.e. how does the payment form know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is producing when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
R

Rob Oldfield

So you're saying that when you run through the code where, for example, the
total field is 10, and the total of the payments is also 10, that it's
correctly figuring out that total2 is also 10, that it is actually getting
to the line Forms!Order!Status = 13 but that the form is still showing a 10?

That can't possibly happen.

Would it be possible to zip the db up (removing any large chunks of data
where not required) and mail it to me?


Mattias said:
Rob

Tried the bound one. It did run throw the code all the way. The one I want
set to 13 had the value 10 but did not change it....

Mattias

Rob Oldfield said:
Hmmm. Can't see how that's not working. Try stepping through the code....
if you're setting Total2 to 10, for example, and Total is 20... then it must
work.

(Just in case you don't know how.... put the cursor on the If
Forms!Order!Total2 =Forms!Order!Total Then line... hit F9 to toggle a
breakpoint.... go through attempting to use the code and it will stop at
that line... hit F8 to move to the next line.... or F5 to carry on as usual)

Where does it go? Does it get to the Forms!Order!Status = 13 line?


Mattias said:
Hi again.

I removed the subform now!! Tried your original idea to sum the
payments
in
the paymentform close event. But to make it work completly I had to ad sum
creditcardfee and curryency exchange fee. I also added a nz to be albe to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go to
the
next
record and back again...the only value being saved and still correct
is
the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and
CurrencyExchangefee
to
the ordertable and the form controls bound to the new fields. It saves the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub



:

Couple of things....

Why do you think you need the subform? (....that's assuming that
the
one
that you're talking about is the same one that I'm thinking about... the
hidden one?)

The subform won't do anything in the code you're attached because
it's
not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way you're
linking the data entered on the payments form back to the original order.
What code are you using to open that? (i.e. how does the payment
form
know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is
producing
when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
G

Guest

Ok thank you!!

How big maximum and where to..?

Mattias

Rob Oldfield said:
So you're saying that when you run through the code where, for example, the
total field is 10, and the total of the payments is also 10, that it's
correctly figuring out that total2 is also 10, that it is actually getting
to the line Forms!Order!Status = 13 but that the form is still showing a 10?

That can't possibly happen.

Would it be possible to zip the db up (removing any large chunks of data
where not required) and mail it to me?


Mattias said:
Rob

Tried the bound one. It did run throw the code all the way. The one I want
set to 13 had the value 10 but did not change it....

Mattias

Rob Oldfield said:
Hmmm. Can't see how that's not working. Try stepping through the code....
if you're setting Total2 to 10, for example, and Total is 20... then it must
work.

(Just in case you don't know how.... put the cursor on the If
Forms!Order!Total2 =Forms!Order!Total Then line... hit F9 to toggle a
breakpoint.... go through attempting to use the code and it will stop at
that line... hit F8 to move to the next line.... or F5 to carry on as usual)

Where does it go? Does it get to the Forms!Order!Status = 13 line?


Hi again.

I removed the subform now!! Tried your original idea to sum the payments
in
the paymentform close event. But to make it work completly I had to ad sum
creditcardfee and curryency exchange fee. I also added a nz to be albe to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go to the
next
record and back again...the only value being saved and still correct is
the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and CurrencyExchangefee
to
the ordertable and the form controls bound to the new fields. It saves the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub



:

Couple of things....

Why do you think you need the subform? (....that's assuming that the
one
that you're talking about is the same one that I'm thinking about... the
hidden one?)

The subform won't do anything in the code you're attached because it's
not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way
you're
linking the data entered on the payments form back to the original
order.
What code are you using to open that? (i.e. how does the payment form
know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is producing
when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
R

Rob Oldfield

As long it's not absolutely massive, then don't worry about the maximum....
zen13426 followed by one of those strange @ symbol things followed by
zen.co.uk (just avoiding it getting picked up by any of those nasty spam
harvesting bots)


Mattias said:
Ok thank you!!

How big maximum and where to..?

Mattias

Rob Oldfield said:
So you're saying that when you run through the code where, for example, the
total field is 10, and the total of the payments is also 10, that it's
correctly figuring out that total2 is also 10, that it is actually getting
to the line Forms!Order!Status = 13 but that the form is still showing a 10?

That can't possibly happen.

Would it be possible to zip the db up (removing any large chunks of data
where not required) and mail it to me?


Mattias said:
Rob

Tried the bound one. It did run throw the code all the way. The one I want
set to 13 had the value 10 but did not change it....

Mattias

:


Hmmm. Can't see how that's not working. Try stepping through the code....
if you're setting Total2 to 10, for example, and Total is 20... then
it
must
work.

(Just in case you don't know how.... put the cursor on the If
Forms!Order!Total2 =Forms!Order!Total Then line... hit F9 to toggle a
breakpoint.... go through attempting to use the code and it will stop at
that line... hit F8 to move to the next line.... or F5 to carry on
as
usual)
Where does it go? Does it get to the Forms!Order!Status = 13 line?


Hi again.

I removed the subform now!! Tried your original idea to sum the payments
in
the paymentform close event. But to make it work completly I had
to ad
sum
creditcardfee and curryency exchange fee. I also added a nz to be
albe
to
handle null values.

For the first time it set paymentstatus ok for the current record...but
since removing the subform it does not keep the values in the unbound
controls Total2, Creditcardfee and CurrencyExchangefee, when I go
to
the
next
record and back again...the only value being saved and still
correct
is
the
bound Status
control.

Tried one idea I had..added Total2, Creditcardfee and CurrencyExchangefee
to
the ordertable and the form controls bound to the new fields. It
saves
the
values ok but it does not change the status anymore...

Mattias
Private Sub Form_Close()
Dim Total As Currency
Dim Total2 As Currency
Dim Status As Long
Dim CurrencyExchangeFee2 As Currency
Dim CreditcardFee2 As Currency

Total2 = DSum("[Amount]", "Paymentsqry", "[Orderno]=" + CStr(Me.Orderno))
Forms!Order!Total2 = Nz([Total2])
Creditcardfee2= DSum("[creditcardfee]", "Paymentsqry", "[Orderno]=" +
CStr(Me.Orderno))
Forms!Order!Creditcardfee = Nz([Creditcardfee2])
CurrencyExchangeFee2= DSum("[CurrencyExchangeFee]", "Paymentsqry",
"[Orderno]=" + CStr(Me.Orderno))
Forms!ExpeditionUtlämning!CurrencyExchangeFee = Nz([CurrencyExchangeFee2])
If Forms!Order!Total2 =Forms!Order!Total Then
Forms!Order!Status = 13
End If
If Forms!Order!Total2 < Forms!Order!Total Then
Forms!Order!Status = 12
End If
If (IsNull(Forms!Order!Total2)) Then
Forms!Order!Status = 10
End If

End Sub



:

Couple of things....

Why do you think you need the subform? (....that's assuming
that
the
one
that you're talking about is the same one that I'm thinking
about...
the
hidden one?)

The subform won't do anything in the code you're attached
because
it's
not
being told to. What happens if you drop in a...

forms!order!subformcontrolname.requery

....after the dim statements in the close routine?

I'm beginning to suspect that there's something wrong with the way
you're
linking the data entered on the payments form back to the original
order.
What code are you using to open that? (i.e. how does the
payment
form
know
that it's linked back to the order?)

And I'd still like to know what
dsum("[Amount]","Payments","[OrderID]="+cstr(me.orderid)) is producing
when
you first close the payments form.

<snipping the rest of the thread as it's getting a bit cumbersome>
 
G

Guest

Your problem is due to the fact that the first Activate event fires before
the form becomes visible on the screen. Admittedly, this is idiotic, but
then Microsoft is idiotic and Access is a piece of crap, so what's the
surprise?
 
J

John Nurick

Hi Mattias,

Mek's not quite correct: the problem is caused by the fact that the
Activate event fires whenever the form becomes active (it's irrelevant
in this context whether it's visible or not) and not just when you
switch to it from the payment form. That's hardly idiotic behaviour
(although it's not always obvious what counts as "becoming active" and
therefore when the event will file).

In this situation, it's best to set the paymentstatus explicitly from
the payment form. If the payment form has an OK button, the button's
Click event procedure would be the place to do it. Otherwise, the
payment form's Close event procedure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top