Results 1 to 11 of 11

Thread: checkboxes

  1. #1
    Join Date
    Nov 2003
    Location
    New Zealand
    Posts
    47

    Unhappy Unanswered: checkboxes

    hey guys, thanks in advance I love using this forum.

    my problem is.......I have a form with a subform on it subform1. i want to use checkboxes to hide fields in subform1. i want to be able to limit which fields the user enters data into by choosing them from by ticking the check box option. Does this make since. can it be done.

    heres more detail.

    the subform has these fields to fill in.
    purchase
    lease 6 months
    lease 12 months
    lease 24 months
    lease 36 months
    lease 48months

    now to prevent typing into the wrong field i want to hide the fields that aren't needed. the subform is in datasheet view. can i do this with check boxes.

    thank you
    Nerdy Girl

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Would it be acceptable to disable the fields instead of hiding them? That would be quite a bit easier.. In that case you could write a fairly simple sub for onchange in the checkbox and set field.enabled accordingly.

  3. #3
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Please don't take this as me purporting to know your business, but I am wondering, given the choices, why you are using checkboxes instead of either a combo box, or an option group. If something is applicable for 6 months, it is not applicable for 48 months? Maybe I misunderstand your question.

    This should worked, it did work once, now it won't work:

    me.YourSubformControlName.Controls("YourNonApplica bleField").ColumnWidth = 0

    But this seems to work:
    me.YourSubFormControlName.Controls("YourNonApplica bleField").Locked = True

    If you're going to use an If or Select Case, remember to reset the .Locked property of any controls that could be chosen as non applicable, or you will slowly lock them up.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  4. #4
    Join Date
    Nov 2003
    Location
    New Zealand
    Posts
    47
    I am generating a quote, so i want to show the prices for a product over the different lease times.

    Your idea about locking the fields or Hiding them is exactly what i am looking for.

    I do plan on using a 'if' statement to detemine which fields in the subform to hide and not hide.

    can you show me the code for doing this in the if staement.
    could you explain to me the sections in your line of code........Applicable.............control........ not sure about these....are they my subform and the checkbox that I have on my form....

    I hope im not asking to much.

    thanks everyone these ideas have really helped me out.
    Nerdy Girl

  5. #5
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    Oh sorry about the slangauge,

    YourSubFormControlName: The control name of the subform on the main form

    YourNonApplicableField: The name of the control on the subform which you wish to lock

    What I would do is have one routine that evaluates the status of the checkboxes and have each checkboxes OnClick call the function. This is one of the downsides of using multiple checkboxes to control one 'thing' (your subform, in this case).

    Function LockControls()
    if me.chkPurchase then me.YourSubFormControlName.Controls("YourNonApplica bleField").Locked = True

    if me.chkSixMos then me.YourSubFormControlName.Controls("YourNonApplica bleField").Locked = True

    etc.

    Because the value of the checkbox is 0 or -1, this corresponds to false and true respectively. Because you are only doing one thing per checkbox true value, you can use an in-line if w/o and End If.

    HTH.

    Let me know if this is unclear
    All code ADO/ADOX unless otherwise specified.
    Mike.

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by nerdy_girl
    I am generating a quote, so i want to show the prices for a product over the different lease times.

    Your idea about locking the fields or Hiding them is exactly what i am looking for.

    I do plan on using a 'if' statement to detemine which fields in the subform to hide and not hide.

    can you show me the code for doing this in the if staement.
    could you explain to me the sections in your line of code........Applicable.............control........ not sure about these....are they my subform and the checkbox that I have on my form....

    I hope im not asking to much.

    thanks everyone these ideas have really helped me out.
    A combo box would be a might nicer way to do this, or a listbox.

    I am just finishing a quote/rating system for a medium size insurance company myself. Feel free to pm/email me with any ideas you'd like to bounce around. I LOVE to swap ideas. There's always something I would have never thought of.

    I'd be most curious to see how you set this up, as I took a bit different approach.


  7. #7
    Join Date
    Nov 2003
    Location
    New Zealand
    Posts
    47
    Thanks guys for all you feed back.

    I will try your sujestions homerboo and get back to you on my progress.

    Thank you teddy, i would love to share and discuss ideas with you. I would love to see your approach to this type of project. Things here are crazy, being xmas and all. I will try to get back to both of you within the week.

    thanks heaps really appreciate the time you have taken to help me.

    nerdy_girl
    Nerdy Girl

  8. #8
    Join Date
    Nov 2003
    Location
    New Zealand
    Posts
    47
    Hi HomerBoo.

    I have used the bothe these methods and your right the first one only works once how anoyning. This is exactly what i am after if only it would work. Did you have problems trying to enlarge the column width after you set it to 0.

    me.YourSubformControlName.Controls("YourNonApplica bleField").ColumnWidth = 0

    But this seems to work:
    me.YourSubFormControlName.Controls("YourNonApplica bleField").Locked = True

    locking the fields does achieve what i need, just a bit messy.

    Thank you this was good.

    Teddy, how would this work with a combobox?

    could you change the locked property depending on the choice made in the combox? would this not be confusing. You would have to test the fields to determine weather they active? Am I on the right track with this. A combobox would be tidy.


    thank you for your help everyone
    Nerdy Girl

  9. #9
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Originally posted by nerdy_girl

    Teddy, how would this work with a combobox?

    could you change the locked property depending on the choice made in the combox? would this not be confusing. You would have to test the fields to determine weather they active? Am I on the right track with this. A combobox would be tidy.
    If you could attach a screenshot or a sample db I could better clarify my approach to fit what you're doing. I'm not sure exactly how you want it to look just yet.


  10. #10
    Join Date
    Dec 2003
    Posts
    268

    Possible Solutions

    There are two possible solutions for this one (Assuming that you wouldn't allow for more than one lease type to be selected at a time).

    You could either use a frame to store the information or you could determine the selection in a list/combo box.

    I have created a sample DB that allows for either option.

    For the SubForm: I created 8 labels and 8 text boxes. For each of the items I have taken advantage of the tag value for each control. I have put in the respective index for which the information should be displayed, and set all items in the subform to visible = false. i.e. If lbl1, lbl2, txt1 and txt2 should be shown for a 6 month lease their tag value has been set to 1.

    For Frame: I created a frame. Which holds an array of option buttons. When an item is selected in a frame the system only allows for one selection to be made at a time. This frame then stores a value of the index of the item selected. In this example 1-4. Based on the selected value I pass this parameter into a sub routine called HideStuff.

    For ComboBox: To feed the combo box I created a table called tblLease. This stores information in two columns; LeasePeriod and LeaseID. I followed the same index information as would have been determined by the frame. The combo box is has a rowsource defined as "SELECT * FROM tblLeaseInfo" I then set the bound column to 2 and set the column width to 1.5 and 0. This will not show the information from the second column, but will make the information accessible. Based on the selected item in the combo box I pass this information to a sub routine called HideSuff.

    HideStuff: Accepts a parameter, which is the index of the selected item.
    It then takes this value and compares it to the tag value for each item in the subform. If the values match it then changes the controls visibility to true. If the values do not match it then sets it to false.

    NOTE: I created a subroutine to do this because I didn't want to retype the same code. Not trying to make spaghetti code here. Other than that there is really no advantage to keeping them separate.

    I have included a copy of the DB. Any questions just let me know. addy is in the code.
    Attached Files Attached Files

  11. #11
    Join Date
    Nov 2003
    Location
    New Zealand
    Posts
    47
    Hi thanks for you advice and im sorry it has taken me so long to reply.

    The thing is that, the user will be able to select more than one lease option.

    Thanks for the db example, I'm definate that it will help me out later on.

    Teddy sorry for the late reply, its really busy here at xmas.......I love xmas shopping, anyway i would love a sample of how you achieved this with a combobox......always keen to learn how others solutions work.

    thanks
    Nerdy Girl

Posting Permissions

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