Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Location
    Manchester, NH
    Posts
    57

    Unanswered: using checkbox to change the value of another field value

    I am trying to change the value of field duespaidtodate depending on the value of field check72. I have the value of the field duespaidtodate set at $144 at creation, and I have the value of check72 set to selected (checked). What I want to happen is that if the user unchecks the check72 box, it will set the value of duespaiddate to $0, and if the value is set at $0 I want it to change it to $144. This is what I wrote in the AfterUpdate event of the check72 field, but I'm geting errors:

    If Me.Check72.Value = True Then Set Me.DuesPaidDate.Value = 144
    Else
    If Me.Check72.Value = False Then Set Me.DuesPaidDate.Value = 0
    Else

    End If

    I am getting an error that says " Compile Error: Else without If"..

    I am at a loss here, any help would be great!

    Thanks, Dalynch

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    This is an in-line If statement:
    If Me.Check72.Value = True Then Set Me.DuesPaidDate.Value = 144

    There is no other conditional structure allowed with an in-line If.

    You probably want:

    If Me.Check72.Value = True Then
    Set Me.DuesPaidDate.Value = 144
    ElseIf Me.Check72.Value = False Then Set Me.DuesPaidDate.Value = 0
    Else

    End If

    You also have two Elses in your original statement, please note the change to ElseIf for the first one. The Else is terminal, if you want to add another Else after this, you'll need another if:

    If something Then
    ElseIf somethingElse then
    else
    if somethingEvenMore then
    else
    end if
    end if
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Apr 2003
    Location
    Manchester, NH
    Posts
    57

    ok, now i'm getting a runtime error 424

    Object required

    When I go to debug it tells me that:

    Me.Check72.Value = 0

    Me.DuesPaidDate.Value = 144

    Any ideas?

    Dalynch

  4. #4
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Dalynch,

    I apologise if I misled you. I had meant to address the structure of your If.Then...ElseIf...Else construct. If you actually want it to work (why would you want that?), use the code below. I've attached it to the check72_click event, note that I haven't used another evaluative statement in the code as the value of Check72 is binary when clicked (i.e., not when it is in triple state):

    If Me.Check72.Value = True Then
    Me.DuesPaidDate.Value = 144
    Else
    Me.DuesPaidDate.Value = 0
    End If

    HTH

    Mike.
    All code ADO/ADOX unless otherwise specified.
    Mike.

Posting Permissions

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