A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with code problem on form



 
 
Thread Tools Display Modes
  #1  
Old September 14th, 2005, 05:08 PM
Randy
external usenet poster
 
Posts: n/a
Default Help with code problem on form

I have a form which includes the following 4 fields all numbers: [Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9, FM=0.
This example equals exactly 3000.2 but my message box is popping up. If
the [Sample] data entry is exactly 3000 or any other number without tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


  #2  
Old September 15th, 2005, 02:31 AM
RuralGuy
external usenet poster
 
Posts: n/a
Default

You could easily be up against a timing problem. I'm assuming your control
source for the [FM] *control* (records have fields, forms have controls) is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will update the
[FM] control before you leave the [Ined] control. Maybe and maybe not. I
suppose you could issue a DoEvents to give Access some time but there is a far
better solution: Your code should be in the BeforeUpdate event of the *Form*
and not the control. All of the controls will be up to date before Access
attempts to save the record. That is where you make your test and Cancel the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy" wrote:

I have a form which includes the following 4 fields all numbers: [Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9, FM=0.
This example equals exactly 3000.2 but my message box is popping up. If
the [Sample] data entry is exactly 3000 or any other number without tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
  #3  
Old September 15th, 2005, 02:51 AM
Randy
external usenet poster
 
Posts: n/a
Default

I tried your suggestion in the before event of my form, but the msgbox still
pops up even though [FM] is not less than 0...Could it be something in th
rounding of numbers? Entries are now in tenths. Previously entries were in
whole numbers (3000.0) Ive used this code for 3 years without any problems.
But when entries are to the tenth, msgbox pops up, but not always. works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
...
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe not. I
suppose you could issue a DoEvents to give Access some time but there is a
far
better solution: Your code should be in the BeforeUpdate event of the
*Form*
and not the control. All of the controls will be up to date before Access
attempts to save the record. That is where you make your test and Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy" wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up. If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



  #4  
Old September 15th, 2005, 02:59 AM
RuralGuy
external usenet poster
 
Posts: n/a
Default

I forgot to mention that you are using 0 rather than 0. I would change it.
If my assumptions are correct, I don't believe any rounding is taking place
unless you are doing some multiplication or division somewhere. Still I use the
Currency data type whenever 4 decimal places will do and I do my own rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and see what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox still
pops up even though [FM] is not less than 0...Could it be something in th
rounding of numbers? Entries are now in tenths. Previously entries were in
whole numbers (3000.0) Ive used this code for 3 years without any problems.
But when entries are to the tenth, msgbox pops up, but not always. works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
.. .
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe not. I
suppose you could issue a DoEvents to give Access some time but there is a
far
better solution: Your code should be in the BeforeUpdate event of the
*Form*
and not the control. All of the controls will be up to date before Access
attempts to save the record. That is where you make your test and Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy" wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up. If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
  #5  
Old September 15th, 2005, 03:12 AM
Randy
external usenet poster
 
Posts: n/a
Default

I need 0 because [FM] is frequently 0 or more than 0 but it can never be
less than 0 (-0)
RuralGuy wrote in message
...
I forgot to mention that you are using 0 rather than 0. I would
change it.
If my assumptions are correct, I don't believe any rounding is taking
place
unless you are doing some multiplication or division somewhere. Still I
use the
Currency data type whenever 4 decimal places will do and I do my own
rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and see
what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox
still
pops up even though [FM] is not less than 0...Could it be something in th
rounding of numbers? Entries are now in tenths. Previously entries were
in
whole numbers (3000.0) Ive used this code for 3 years without any
problems.
But when entries are to the tenth, msgbox pops up, but not always.
works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
. ..
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe not.
I
suppose you could issue a DoEvents to give Access some time but there is
a
far
better solution: Your code should be in the BeforeUpdate event of the
*Form*
and not the control. All of the controls will be up to date before
Access
attempts to save the record. That is where you make your test and
Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy" wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up.
If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



  #6  
Old September 15th, 2005, 03:20 AM
RuralGuy
external usenet poster
 
Posts: n/a
Default

Got it. What type of fields are [Sample]-[Edible]-[Ined]? Did you try the
MsgBox test?

On Wed, 14 Sep 2005 19:12:38 -0700, "Randy" wrote:

I need 0 because [FM] is frequently 0 or more than 0 but it can never be
less than 0 (-0)
RuralGuy wrote in message
.. .
I forgot to mention that you are using 0 rather than 0. I would
change it.
If my assumptions are correct, I don't believe any rounding is taking
place
unless you are doing some multiplication or division somewhere. Still I
use the
Currency data type whenever 4 decimal places will do and I do my own
rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and see
what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox
still
pops up even though [FM] is not less than 0...Could it be something in th
rounding of numbers? Entries are now in tenths. Previously entries were
in
whole numbers (3000.0) Ive used this code for 3 years without any
problems.
But when entries are to the tenth, msgbox pops up, but not always.
works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
...
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe not.
I
suppose you could issue a DoEvents to give Access some time but there is
a
far
better solution: Your code should be in the BeforeUpdate event of the
*Form*
and not the control. All of the controls will be up to date before
Access
attempts to save the record. That is where you make your test and
Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy" wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up.
If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
  #7  
Old September 15th, 2005, 03:32 AM
Randy
external usenet poster
 
Posts: n/a
Default

Numbers, Format fixed, decimal places 1, Double integer in table
I dont know how to do the msgBox test...Randy
RuralGuy wrote in message
...
Got it. What type of fields are [Sample]-[Edible]-[Ined]? Did you try
the
MsgBox test?

On Wed, 14 Sep 2005 19:12:38 -0700, "Randy" wrote:

I need 0 because [FM] is frequently 0 or more than 0 but it can never
be
less than 0 (-0)
RuralGuy wrote in message
. ..
I forgot to mention that you are using 0 rather than 0. I would
change it.
If my assumptions are correct, I don't believe any rounding is taking
place
unless you are doing some multiplication or division somewhere. Still I
use the
Currency data type whenever 4 decimal places will do and I do my own
rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and
see
what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox
still
pops up even though [FM] is not less than 0...Could it be something in
th
rounding of numbers? Entries are now in tenths. Previously entries
were
in
whole numbers (3000.0) Ive used this code for 3 years without any
problems.
But when entries are to the tenth, msgbox pops up, but not always.
works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
m...
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have
controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe
not.
I
suppose you could issue a DoEvents to give Access some time but there
is
a
far
better solution: Your code should be in the BeforeUpdate event of the
*Form*
and not the control. All of the controls will be up to date before
Access
attempts to save the record. That is where you make your test and
Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy"
wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up.
If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



  #8  
Old September 15th, 2005, 03:50 AM
RuralGuy
external usenet poster
 
Posts: n/a
Default

Here's how you put the Diagnostic code in the Form BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then

'*** Diagnostic code on the following line
MsgBox "[FM] is equal to " & [FM] & ""
'*** End of diagnostic code

MsgBox "Edible Kernels and/or Inedible Kernels Exceed the " & _
" Sample Size. Foreign Material Has a Negative " & _
"Number. Please Correct Edible or Inedible Kernels."
Cancel = True
End If

End Sub

For now, take the Format Fixed off and change them to General Numbers so you can
see what is going on!

On Wed, 14 Sep 2005 19:32:25 -0700, "Randy" wrote:

Numbers, Format fixed, decimal places 1, Double integer in table
I dont know how to do the msgBox test...Randy
RuralGuy wrote in message
.. .
Got it. What type of fields are [Sample]-[Edible]-[Ined]? Did you try
the
MsgBox test?

On Wed, 14 Sep 2005 19:12:38 -0700, "Randy" wrote:

I need 0 because [FM] is frequently 0 or more than 0 but it can never
be
less than 0 (-0)
RuralGuy wrote in message
...
I forgot to mention that you are using 0 rather than 0. I would
change it.
If my assumptions are correct, I don't believe any rounding is taking
place
unless you are doing some multiplication or division somewhere. Still I
use the
Currency data type whenever 4 decimal places will do and I do my own
rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and
see
what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox
still
pops up even though [FM] is not less than 0...Could it be something in
th
rounding of numbers? Entries are now in tenths. Previously entries
were
in
whole numbers (3000.0) Ive used this code for 3 years without any
problems.
But when entries are to the tenth, msgbox pops up, but not always.
works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
om...
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have
controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe
not.
I
suppose you could issue a DoEvents to give Access some time but there
is
a
far
better solution: Your code should be in the BeforeUpdate event of the
*Form*
and not the control. All of the controls will be up to date before
Access
attempts to save the record. That is where you make your test and
Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy"
wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent a
negative number from occuring in [FM]. [Edible], [Ined] and [FM] must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3, Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up.
If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
  #9  
Old September 15th, 2005, 04:01 AM
Randy
external usenet poster
 
Posts: n/a
Default

I get a message of: [FM] is equal to -4.54747350886464E-13

RuralGuy wrote in message
...
Here's how you put the Diagnostic code in the Form BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then

'*** Diagnostic code on the following line
MsgBox "[FM] is equal to " & [FM] & ""
'*** End of diagnostic code

MsgBox "Edible Kernels and/or Inedible Kernels Exceed the " & _
" Sample Size. Foreign Material Has a Negative " & _
"Number. Please Correct Edible or Inedible Kernels."
Cancel = True
End If

End Sub

For now, take the Format Fixed off and change them to General Numbers so
you can
see what is going on!

On Wed, 14 Sep 2005 19:32:25 -0700, "Randy" wrote:

Numbers, Format fixed, decimal places 1, Double integer in table
I dont know how to do the msgBox test...Randy
RuralGuy wrote in message
. ..
Got it. What type of fields are [Sample]-[Edible]-[Ined]? Did you try
the
MsgBox test?

On Wed, 14 Sep 2005 19:12:38 -0700, "Randy" wrote:

I need 0 because [FM] is frequently 0 or more than 0 but it can never
be
less than 0 (-0)
RuralGuy wrote in message
m...
I forgot to mention that you are using 0 rather than 0. I would
change it.
If my assumptions are correct, I don't believe any rounding is taking
place
unless you are doing some multiplication or division somewhere. Still
I
use the
Currency data type whenever 4 decimal places will do and I do my own
rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and
see
what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox
still
pops up even though [FM] is not less than 0...Could it be something in
th
rounding of numbers? Entries are now in tenths. Previously entries
were
in
whole numbers (3000.0) Ive used this code for 3 years without any
problems.
But when entries are to the tenth, msgbox pops up, but not always.
works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
news:quihi159el28eepchhv1v8rkcjkuebl28p@4ax. com...
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have
controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access
will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe
not.
I
suppose you could issue a DoEvents to give Access some time but
there
is
a
far
better solution: Your code should be in the BeforeUpdate event of
the
*Form*
and not the control. All of the controls will be up to date before
Access
attempts to save the record. That is where you make your test and
Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy"
wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent
a
negative number from occuring in [FM]. [Edible], [Ined] and [FM]
must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3,
Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up.
If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible
or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



  #10  
Old September 15th, 2005, 04:09 AM
RuralGuy
external usenet poster
 
Posts: n/a
Default

Well that is definately less that zero! Do you do any multiplication or
division on any of these numbers? You may have to clean up your data.

On Wed, 14 Sep 2005 20:01:39 -0700, "Randy" wrote:

I get a message of: [FM] is equal to -4.54747350886464E-13

RuralGuy wrote in message
.. .
Here's how you put the Diagnostic code in the Form BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then

'*** Diagnostic code on the following line
MsgBox "[FM] is equal to " & [FM] & ""
'*** End of diagnostic code

MsgBox "Edible Kernels and/or Inedible Kernels Exceed the " & _
" Sample Size. Foreign Material Has a Negative " & _
"Number. Please Correct Edible or Inedible Kernels."
Cancel = True
End If

End Sub

For now, take the Format Fixed off and change them to General Numbers so
you can
see what is going on!

On Wed, 14 Sep 2005 19:32:25 -0700, "Randy" wrote:

Numbers, Format fixed, decimal places 1, Double integer in table
I dont know how to do the msgBox test...Randy
RuralGuy wrote in message
...
Got it. What type of fields are [Sample]-[Edible]-[Ined]? Did you try
the
MsgBox test?

On Wed, 14 Sep 2005 19:12:38 -0700, "Randy" wrote:

I need 0 because [FM] is frequently 0 or more than 0 but it can never
be
less than 0 (-0)
RuralGuy wrote in message
om...
I forgot to mention that you are using 0 rather than 0. I would
change it.
If my assumptions are correct, I don't believe any rounding is taking
place
unless you are doing some multiplication or division somewhere. Still
I
use the
Currency data type whenever 4 decimal places will do and I do my own
rounding.

As a diagnostic, put a MsgBox just after the test to display [FM] and
see
what
is in there.

On Wed, 14 Sep 2005 18:51:16 -0700, "Randy" wrote:

I tried your suggestion in the before event of my form, but the msgbox
still
pops up even though [FM] is not less than 0...Could it be something in
th
rounding of numbers? Entries are now in tenths. Previously entries
were
in
whole numbers (3000.0) Ive used this code for 3 years without any
problems.
But when entries are to the tenth, msgbox pops up, but not always.
works
great if all entries are in whole numbers, not to the tenth...Randy
RuralGuy wrote in message
news:quihi159el28eepchhv1v8rkcjkuebl28p@4ax .com...
You could easily be up against a timing problem. I'm assuming your
control
source for the [FM] *control* (records have fields, forms have
controls)
is a
formula like =[Sample]-[Edible]-[Ined]. You are assuming Access
will
update the
[FM] control before you leave the [Ined] control. Maybe and maybe
not.
I
suppose you could issue a DoEvents to give Access some time but
there
is
a
far
better solution: Your code should be in the BeforeUpdate event of
the
*Form*
and not the control. All of the controls will be up to date before
Access
attempts to save the record. That is where you make your test and
Cancel
the
event if you do not like the results of the test.


On Wed, 14 Sep 2005 09:08:50 -0700, "Randy"
wrote:

I have a form which includes the following 4 fields all numbers:
[Sample],
[Edible], [Ined], and [FM] I have code in before update to prevent
a
negative number from occuring in [FM]. [Edible], [Ined] and [FM]
must
equall [Sample]. Example: Sample=3000.2, Edible=2987.3,
Ined=12.9,
FM=0.
This example equals exactly 3000.2 but my message box is popping up.
If
the [Sample] data entry is exactly 3000 or any other number without
tenths,
everything works fine. Any ideas what is happening? Thanks...Randy

Private Sub InedibleKernelslbl_BeforeUpdate(Cancel As Integer)
If [FM] 0 Then
If MsgBox("Edible Kernels and/or Inedible Kernels Exceed The
Sample
Size. Foreign Material Has a Negative Number. Please Correct Edible
or
Inedible Kernels.", vbYes + vbDefaultButton2) vbYes Then
'Cancel = True
End If
End If
End Sub


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.


_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.



_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Intermitant failure to send e-mail in Outlook 2002 Bob J General Discussion 6 June 29th, 2005 04:47 AM
error 550 won't deliver theMooooo General Discussion 3 March 29th, 2005 12:47 PM
Problem with VBA Code behind form Tom Using Forms 11 February 21st, 2005 05:42 PM
Problem with VBA Code behind form Tom General Discussion 11 February 21st, 2005 05:42 PM
Excellent Navigation Method! Bill Mitchell Using Forms 3 December 16th, 2004 01:49 PM


All times are GMT +1. The time now is 05:16 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.