If Statement - when condtions are not met, then leave field alone

cookitup

Registered User.
Local time
Yesterday, 21:13
Joined
Apr 4, 2012
Messages
33
I am trying to make sure 2 conditions are met before changing the field. If one of those conditions is NOT met, Then I want the fields to be left alone.
Here is my beginner, Feable attempt at doing this:

Private Sub Quote_Amount_AfterUpdate()
If Me.Quote_Amount.Value > 0 & Me.Job_Number.Value = 0 Then
Me.Date_Bid_Sent = Now()
Me.Status.Value = "Have Pricing"
Else
Me.Date_Bid_Sent = 0
End If
End Sub

What I amtrying to do is, if if the quote amount is added after the Job number has been added. I want the fields to remain as they are. If no job number is given, (Me.Job_Number.Value = 0) then I want the fields to change per the syntax above.
I know there is plenty missing here, Could someone help me with this!!
 
If Me.Quote_Amount.Value > 0 & Me.Job_Number.Value = 0 Then

You have Three parts. If----Then------Else.

You just need to use the THEN as a second If or if you prefer Then If
Code:
[B]If [/B]Me.Quote_Amount.Value > 0 ,If Me.Job_Number.Value = 0, Then 
   Me.Date_Bid_Sent = Now()
   Me.Status.Value = "Have Pricing"
      Else
      Me.Date_Bid_Sent = 0
End If

Let me know if this doesn't work the way you want.
 
I am VERY new at coding. Could you give me an example of what you are saying???
 
I did

What do you think the code is.
 
Rainy, I looked to quickly at the code, and missed the second IF...Sorry (I thought it was the same code I sent you)...My Bad!
However, I am now getting a syntax error on this line:
If Me.Quote_Amount.Value > 0 ,If Me.Job_Number.Value = 0, Then
Me.Date_Bid_Sent = Now()
Me.Status.Value = "Have Pricing"
Else
Me.Date_Bid_Sent = 0
End If

I will pay closer attention!
 
If (Me.Quote_Amount.Value > 0 ,If (Me.Job_Number.Value = 0,)) Then


Sorry about that.
 
If I remember correctly Excel has a Tool to build this type of expression.

It automatically does the syntax.

I am off like a bucket of prawns in the sun.

Back tomorrow.
 
Private Sub Quote_Amount_AfterUpdate()
If (Me.Quote_Amount.Value > 0 ,If (Me.Job_Number.Value = 0,)) Then
Me.Date_Bid_Sent = Now()
Me.Status.Value = "Have Pricing"
Else
Me.Date_Bid_Sent = 0
End If
End Sub
This is still saying Compile Error Expected:) at the , I appreciate all your help Rainy(enjoy your time off :) ), is there anyone else who can help????
 
Code:
Private Sub Quote_Amount_AfterUpdate()
If Me.Quote_Amount > 0 AND Me.Job_Number = 0 Then
    Me.Date_Bid_Sent = Now()
    Me.Status = "Have Pricing"
End If
End Sub
If you don't want a field to change, then don't give it a new value. I removed the .Value property because it is redundant. .Value is the default property for a control.
 

Users who are viewing this thread

Back
Top Bottom