Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    1

    Unanswered: store a different value when checkbox is checked

    Hi,

    I have a checkbox on a data entry form in MS access. When it is checked the field in the database has a value of "-1". How can I save the value as "Y" when the checkbox is checked and "N" as the default (unchecked)?

    Also how can I make the checkbox on the form larger so it is easier to see?

    Thank you,


    Gibs

  2. #2
    Join Date
    May 2010
    Posts
    601
    Gibs,

    1) You can't.

    If you really need the value to be text then:
    a) use a combo box.
    b) use an unbound check box and VBA code for displaying and storing the data.

    It is possible to convert the data from -1 and 0 to Y and N as needed.

    For example in the control source of a text bos use:

    =IIF(Nz([YouYesNoFied],0),"Y","N")

    2) You can't change the size of a check box.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    one trick you can do is use an image or slightly dodgier a text box using a font that has the tick and cross symbols. I say dodgier because it depends on the user having that same font on their computer and you cannot guarantee that, not matter whether its wingdings or not

    the trick with the image is to create the images you want and then load them as required.. in the foms on current event
    remember to set a value when you add a new record.

    if you are using bound controls (if you don't know what that means you are)
    place the checkbox as your would normally, but hide it from users view settign the visible property to false

    place some code behind the image controls on click property
    Code:
    if mycheckbox=true then 'set the image
      myimagecontrol.picture="path/to/my/tickboxfalse.jpg"
    else
      myimagecontrol.picture="path/to/my/tickboxtrue.jpg"
    endif
    mycheckbox.value = not mycheckbox.value 'toggle the value of the checkbox
    the downside of that approach is you have make certaint he image is visible to all users. you cna get round that by using a URL eg //servername/server/share/image.jpg

    an alternative is to stuff two image controls on the form preloaded with the oiamge you require and then set those controls visible property as required

    Code:
    if mycheckbox=true then 'set the image
      img_tickboxtrue.visible=  false
      img_tickboxfalse.visible = true
    else
      img_tickboxtrue.visible=  true
      img_tickboxfalse.visible = false
    endif
    mycheckbox.value = not mycheckbox.value 'toggle the value of the checkbox
    you can shorten that to
    Code:
    img_tickboxtrue.visible= not img_tickboxtrue.visible 'toggle the visibility state of the two image boxes
    img_tickboxfalse.visible = not  img_tickboxfalse.visible
    mycheckbox.value = not mycheckbox.value 'toggle the value of the checkbox
    __________________
    Last edited by healdem; 10-04-10 at 04:39.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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