Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2003
    Location
    California
    Posts
    3

    Question Unanswered: If/else question

    I am teaching myself access and need help writing a code for this problem. I have a check box for teacher's and IA's and a field for hour1, amountpaid1. What I want to happen is when I put in 6 for hours, I want $280 to populate the amountpaid1 for teachers and $148 for IA's. I think I would need to do a if/else statment but not sure if I can do that with a check box. I have tried this and it didn't work as I get a compile error message.

    Private Sub hour1_BeforeUpdate(Cancel As Integer)
    If hour1 = 6 Then amountpaid1 = "287.00"
    ElseIf hour1 = 6 Them amountpaid1 = "148.00"
    End If
    End Sub

    Any help would be appriciated.

  2. #2
    Join Date
    Apr 2004
    Location
    outside the rim
    Posts
    1,011
    If you are using code, write yourself a little mini process flow. For example:

    1. User enters Hours into a text box
    2. Another control calculates $$
    2a. Which check box is checked?
    2b. Multuple Hours by the correct number
    2c. Place result into a text box

    Use the After_Update - you want the calculation to happen after the user enters the number of hours.

  3. #3
    Join Date
    Mar 2006
    Posts
    73
    I don't know if that's your actual code there, but you've got them instead of then typed

    but if not try adding .Value or .Text at the end of the fields you are populating.

  4. #4
    Join Date
    Nov 2003
    Location
    California
    Posts
    3
    I will try to do this as and see if it helps. Thanks.

  5. #5
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    Quote Originally Posted by kot
    I am teaching myself access and need help writing a code for this problem. I have a check box for teacher's and IA's and a field for hour1, amountpaid1. What I want to happen is when I put in 6 for hours, I want $280 to populate the amountpaid1 for teachers and $148 for IA's. I think I would need to do a if/else statment but not sure if I can do that with a check box. I have tried this and it didn't work as I get a compile error message.

    Private Sub hour1_BeforeUpdate(Cancel As Integer)
    If hour1 = 6 Then amountpaid1 = "287.00"
    ElseIf hour1 = 6 Them amountpaid1 = "148.00"
    End If
    End Sub

    Any help would be appriciated.
    HI Kot and Welcome to the Forum
    First of all, is that code copied directly from your program? If so, then you need to get the spelling corrected. See what I BOLDED?
    Next, just to me, the logic as it stands doesn't make sense. You are saying that IF hour1 = 6 that amount paid should be 287.00, but then on your next line you are also saying again, IF hour1 = 6 make amountpaid1 = 148.00
    See my point???
    First off, are the values you have for Teachers and IA's set in stone? Or are the calculated somehow? If they are Fixed amounts that are NOT calculated, then simply put that amount in a field for each the Teacher and the IA.
    About as simple as I can make it for you with the info. given.

    have a nice one,
    BUD

  6. #6
    Join Date
    Nov 2003
    Location
    California
    Posts
    3
    Quote Originally Posted by Bud
    HI Kot and Welcome to the Forum
    First of all, is that code copied directly from your program? If so, then you need to get the spelling corrected. See what I BOLDED?
    Next, just to me, the logic as it stands doesn't make sense. You are saying that IF hour1 = 6 that amount paid should be 287.00, but then on your next line you are also saying again, IF hour1 = 6 make amountpaid1 = 148.00
    See my point???
    First off, are the values you have for Teachers and IA's set in stone? Or are the calculated somehow? If they are Fixed amounts that are NOT calculated, then simply put that amount in a field for each the Teacher and the IA.
    About as simple as I can make it for you with the info. given.

    have a nice one,
    BUD
    Opps, I do have a typo that I didn't even notice. I wasn't sure how to delineate the hour1 between the teachers & IA's. If a teacher or IA accumulate 6, 12, or 18 hours, they get paid a certain amount. So I'm wondering if I can do this: If teacher boxed checked and hour1 = 6 then amountpaid1 = 287.00 elseif IA boxed checked and hour1 = 6 then amountpaid1 = 148.00?

  7. #7
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Just like you say:

    Code:
    If chkTeacher.value = -1 AND hour1 = 6 Then
       'Do Some Stuff
    ElseIf chkIA.value = -1 AND hour1 = 6 Then
       'Do Some Other Stuff
    End If
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •