Caclulation Code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good day,

Here is what I am trying to do,

In a subform I have a dropdown menu (Combo box) that has different machines.
Certain information is required inorder to calculate a rate. Basically, If
the user selects a machine and one of the fields is empty a message box comes
up saying "Incomplete information" otherwise if all the information is there
then it does the caculation.

Here is my code however it is not working properly. The message box comes up
when ift is supposed to however the field PCS_HR does not return the value of
1 Any Help would be greatly appreciated.

Private Sub UOM_LostFocus()
IIf [PIECES] = 0, MsgBox("Incomplete Information. Number of PCS/CUT Required
for this process"), PCS_HR = 1

End Sub


Thanks for your help in advance
 
Do you get an error message? What does it say?

I'm not familiar with the syntax your code uses.

What is the purpose of the comma that precedes "PCS_HR = 1"? Are you trying
to set the value or find the value?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Basically It is an If statement. What I am asking the program to do is If the
feild PIECES is qual to 0 then bring up the message incomplete information
because it is required the comma is "then or otherwise", return the value of
1 in the PCS_HR field. I am using 1 just to test. Should be zero becasue THe
PIECES requires a value not equal to zero.

Nope no error message. The message comes up if there is a zero in the PEICES
field and does not come up when there is a value other then zero. Which is
what I want however my PCS_HR does not return a value of 1. Maybe my code is
totaly wrong any suggestions?

My code

Private Sub UOM_LostFocus()
If (Me.PIECES) = 0 Then MsgBox ("Incomplete Information. Number of PCS/CUT
Required for this process"), [Text19] = "Kyle"

I have tried ----
'
'If IsNull(Me.FIELD1) Or IsNull(Me.FIELD2) Then
' MsgBox "Incomplete information"
'Else
' CODE TO CALCULATE RATE
'End If

'where FIELD1 and FIELD2 are fields that can't be null, and the code to
'calculate rate is placed in there.
 
What happend when you tried that other code? The code you first posted
doesn't look like it has the proper syntax.

Where are you calling this procedure from?

Regards

Jeff Boyce
Microsoft Office/Access MVP

K said:
Basically It is an If statement. What I am asking the program to do is If
the
feild PIECES is qual to 0 then bring up the message incomplete information
because it is required the comma is "then or otherwise", return the value
of
1 in the PCS_HR field. I am using 1 just to test. Should be zero becasue
THe
PIECES requires a value not equal to zero.

Nope no error message. The message comes up if there is a zero in the
PEICES
field and does not come up when there is a value other then zero. Which is
what I want however my PCS_HR does not return a value of 1. Maybe my code
is
totaly wrong any suggestions?

My code

Private Sub UOM_LostFocus()
If (Me.PIECES) = 0 Then MsgBox ("Incomplete Information. Number of PCS/CUT
Required for this process"), [Text19] = "Kyle"

I have tried ----
'
'If IsNull(Me.FIELD1) Or IsNull(Me.FIELD2) Then
' MsgBox "Incomplete information"
'Else
' CODE TO CALCULATE RATE
'End If

'where FIELD1 and FIELD2 are fields that can't be null, and the code to
'calculate rate is placed in there.



Jeff Boyce said:
Do you get an error message? What does it say?

I'm not familiar with the syntax your code uses.

What is the purpose of the comma that precedes "PCS_HR = 1"? Are you
trying
to set the value or find the value?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Got it: Thanks though.

Private Sub UOM_LostFocus()
If (Me.MACHINE) = 1034 And (Me.PIECES) = 0 Then
MsgBox ("Incomplete Information. Number of PCS/CUT Required for this process")
Else
PCS_HR = OD + WALL + LENGTH

End If
End Sub


Jeff Boyce said:
What happend when you tried that other code? The code you first posted
doesn't look like it has the proper syntax.

Where are you calling this procedure from?

Regards

Jeff Boyce
Microsoft Office/Access MVP

K said:
Basically It is an If statement. What I am asking the program to do is If
the
feild PIECES is qual to 0 then bring up the message incomplete information
because it is required the comma is "then or otherwise", return the value
of
1 in the PCS_HR field. I am using 1 just to test. Should be zero becasue
THe
PIECES requires a value not equal to zero.

Nope no error message. The message comes up if there is a zero in the
PEICES
field and does not come up when there is a value other then zero. Which is
what I want however my PCS_HR does not return a value of 1. Maybe my code
is
totaly wrong any suggestions?

My code

Private Sub UOM_LostFocus()
If (Me.PIECES) = 0 Then MsgBox ("Incomplete Information. Number of PCS/CUT
Required for this process"), [Text19] = "Kyle"

I have tried ----
'
'If IsNull(Me.FIELD1) Or IsNull(Me.FIELD2) Then
' MsgBox "Incomplete information"
'Else
' CODE TO CALCULATE RATE
'End If

'where FIELD1 and FIELD2 are fields that can't be null, and the code to
'calculate rate is placed in there.



Jeff Boyce said:
Do you get an error message? What does it say?

I'm not familiar with the syntax your code uses.

What is the purpose of the comma that precedes "PCS_HR = 1"? Are you
trying
to set the value or find the value?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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

Back
Top