If And Or

klynch0803

Registered User.
Local time
Today, 17:38
Joined
Jan 25, 2008
Messages
102
I'm stumped for some reason and cant seem to get this to work... Maybe someone can help me out and give me a boost so I can get going again...

I have this and it works perfectly:
Code:
Private Sub CheckSun_AfterUpdate()

    If CheckSun = True And PayType = Salary Then
    
     rs.SundayPay = PayRate
        Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
          
      Else
      
        SundayPay = 0
        Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
    
    End If
    
End Sub

But I need to add in this and I have tried adding it in as another If under under the working one and within it and can't get it to process either way I know I'm missing something or more like forgeting something I just cant figure it out...

Code:
    If CheckSun = True And PayType = Commission Then
    
       SundayPay = (cdbl(SunCom) * (PayRate))
        Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
          
      Else
          
    End If
    
End Sub
 
I would do the CheckSun in one if and embed a second if to the the PayType.

if CheckSun ...
if Paytype...
else ...
end if
else...
...
end if
 
Perhaps you want:

If CheckSun = True And PayType = Salary Then
...
ElseIf CheckSun = True And PayType = Commission Then
...
Else
...
End If
 
Ok So Changed it to this and it recognizes the both of them.. But on the Commission one the "SunCom" value is $200 and the Payrate is .25 why is it giving me .25 in the "SundayPay" instead of $50.00?

Code:
Private Sub CheckSun_AfterUpdate()

    If CheckSun = True Then
    
        If PayType = Salary Then
    
            SundayPay = PayRate
            Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
          
        Else
        End If
     Else
        If PayType = Commission Then
    
            SundayPay = CDbl(SunCom) * CDbl(PayRate)
            Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
          
         Else
         End If
        
        SundayPay = 0
        Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
        
    End If
    
End Sub


LOL WHATS GONNA HAPPEN WHEN I ADD THE 3rd Criteria LOL !! Guess I better pray to the Acces Gods now huh...
 
Just a stab here but I think your next to last end if is in the wrong spot... ?
 
I would suggest you map out all of the variations in some kind of structure on paper and put it all in a series of functions...
 
Just a stab here but I think your next to last end if is in the wrong spot... ?

Your right hmm but where should I put it LOL.. Hmm guessing game LOL..

When I moved it to the end it gave me the $50.00 but only when CheckSun = False LOL...
 
If PayType = Salary Then
If PayType = Commission Then

Unless Salary and Commission in the above code are control/field names, they propbably need to be in quotes

If PayType = "Salary" Then
If PayType = "Commission" Then

I'm assuming that CheckSun is a checkbox where CheckSun = True is a valid value. If it were a textbox, it would require "True" as well.

Linq
 
If PayType = Salary Then
If PayType = Commission Then

Unless Salary and Commission in the above code are control/field names, they propbably need to be in quotes

If PayType = "Salary" Then
If PayType = "Commission" Then

I'm assuming that CheckSun is a checkbox where CheckSun = True is a valid value. If it were a textbox, it would require "True" as well.

Linq

THAT WAS IT "" Ling... Thank YOu I can now go get the super glue and sweep my hair up.. LOL..

Code:
Private Sub CheckSun_AfterUpdate()

    If CheckSun = True And PayScale = "Salary" Then
            
            SundayPay = PayRate
            Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
          
        ElseIf CheckSun = True And PayScale = "Commission" Then
    
            SundayPay = CDbl(SunCom) * CDbl(PayRate)
            Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
            
        ElseIf CheckSun = True And PayScale = "Hourly" Then
            
            SundayPay = CDbl(HrsSun) * CDbl(PayRate)
            Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
      Else
                
        SundayPay = 0
        Me.TotalPayCheck = CDbl(SundayPay) + CDbl(MondayPay) + CDbl(TuesdayPay) + CDbl(WednesdayPay) + CDbl(ThursdayPay) + CDbl(FridayPay) + CDbl(SaturdayPay)
        
    End If
    
End Sub
 
TY TO ALL OF YOU for your help.. If it hadnt been for each of you I wouldn't have gotten where I'am to start the insertion method of this form..
 

Users who are viewing this thread

Back
Top Bottom