Results 1 to 9 of 9

Thread: Check Box

  1. #1
    Join Date
    May 2003
    Location
    Norway
    Posts
    6

    Question Check Box

    Hi can someone plz help me!
    I have a continuous form with one check box for each record ( you can see the form in the attached file).
    What I want is when I set the check box to true or 1 the prize on the record will appere in the textbox in the bottom this I can do with this code:
    =IIf([MotorAggregatValg];[ Pris];0) and it works, but if I want to choose 2 or more of the check box it only shows the latest, I want it to add the priz of each recort an show it in the textbox. I have tryed this
    =Sum(IIf([MotorAggregatValg];[ Pris];0))
    but it only generat an #Error in the textbox.
    Anyone?

  2. #2
    Join Date
    Oct 2002
    Location
    Indiana USA
    Posts
    79
    I'd suggest you write an Event Procedure on the After Update event of the CheckBox control in the form. Use code something like:

    If Me![checkbox]= true then
    Me![MotorAggregatValg]= [pris]
    Else Me![MotorAggregatValg]= ""
    End if

    Hope that helps.
    Herman

  3. #3
    Join Date
    May 2003
    Location
    Norway
    Posts
    6

    Unhappy Still CheckBox trouble MS Access

    Hi Herman
    I tryed to rewrite it a bit like this

    If Me![MotorAggregatValg] = True Then
    Me![MotorAggregatValg] = [Pris]
    Else: Me![MotorAggregatValg] = False
    End If

    but it still only shows the results of the last checkbox I set to true.
    I had to set the Else statment to False if not I only got a Debug when I tried set a CheckBox to false again

  4. #4
    Join Date
    Oct 2002
    Location
    Indiana USA
    Posts
    79
    You're right. I'll try to get back to you after I get a chance to study it, unless someone else answers you sooner.

  5. #5
    Join Date
    May 2003
    Location
    Norway
    Posts
    6

    Smile CheckBox trouble MS Access

    OK thanks man.

  6. #6
    Join Date
    Jan 2004
    Posts
    7
    May be quite dumb but have you tried to "refresh"???

  7. #7
    Join Date
    Oct 2002
    Location
    Indiana USA
    Posts
    79
    RinJacob,

    If I understand your need, I think this will fix it for you.

    Let's say two fields in your source table are [chk] (with yes/no datatype), and
    [price] (text datatype). In your form, let the checkbox control (I'll name
    it [Check4]) have [chk] as its control source. Have two text boxes, one that
    I'll name [Text2] and leave it unbound, the other I'll name [PriceAux] and it
    will have [price] as it's control source. For [PriceAux] set its visibility
    to No.

    For the AfterUpdate event of [chk] write this code:

    Private Sub Check4_AfterUpdate()
    If [Check4] = True Then
    [Text2] = [PriceAux]
    Else: [Text2] = ""
    End If
    End Sub

    For the OnCurrent event of the form write this code:

    Private Sub Form_Current()
    If [Check4] = True Then
    [Text2] = [PriceAux]
    Else: [Text2] = ""
    End If
    End Sub

    As you move through your records, the data in the [price] field of the table
    will always be present in the [PriceAux] control, but you will not be seeing
    it. Whenever you have the [Check4] checked, the price data in [PriceAux] will
    load into [Text2] for you to see. Whenever you uncheck [Check4] the data in
    [Text2] disappears.

  8. #8
    Join Date
    May 2003
    Location
    Norway
    Posts
    6

    Unhappy CheckBox trouble MS Access

    Hermhart
    That workt just the same way as
    =IIf([MotorAggregatValg];[ Pris];0) does.
    What I need it to do is to add the price fields together in the [Text2].
    If I have checked two checkboxes I want the[Text2] to show [Price]+[Price]

    rinjacob

  9. #9
    Join Date
    Oct 2002
    Location
    Indiana USA
    Posts
    79
    OOOOh. As we say in America, the penny has dropped.

    OK. I'd say the logical way to get that is with a report. First make a query with "yes" as the criteria for the checkbox field. Then use that query as the record source for the report. Then in the report footer put a control whose Control Source is =Sum([pris]).

    If you really must have this result in a form rather than a report, then you could use code something like Galileeian offered on 1-8 on the topic of "Concat different rows column into single row field".

    Does that get closer to your need?
    Herman

Posting Permissions

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