Results 1 to 3 of 3
  1. #1
    rossi45 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    12

    Programming Check Box in MS Access


    I am programming a simple check box in MS Access. This is how it goes:

    1. I have a combobox set up with a drop down of values the user can choose from.(i.e. b1, b2, c1, d1, d2, d3, e0, e2, etc) They are just 2 character text strings.
    2. I have a checkbox to be used when the user wants to modify the value in the drop down. Basically all it does is, when the checkbox is checked, it will change any of the values to 'ds(drop down value)" so it just adds the "ds()". (ie. ds(b1), ds(b2), ds(c1), etc)
    3. If the user unchecks the checkbox, then the value stays as the 2 character text string.


    My pseudo code is as follows:


    Private Sub distchk_Click() if distchk is checked then Me.ECOSITE = "ds(" & Me.ECOSITE & ")" else: it doesn't modify the ECOSITE field or, if the user hit the check box accidently,
    when they uncheck it reverts back to the 2 character text string in ECOSITE End Sub I tested:

    Private Sub distchk_Click() Me.ECOSITE = "ds(" & Me.ECOSITE & ")" End Sub but it keeps adding additional ds() anytime I check it, and won't remove it if I uncheck it.
    Any suggestions would be great!
    Mike

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Will this work for you?

    Code:
    Sub distchk_Click()
       If Me.distchk Then
          Me.ECOSITE = "ds(" & Me.ECOSITE & ")"
       Else
          Me.ECOSITE = Replace(Me.ECOSITE, "ds(", "")
          Me.ECOSITE = Replace(Me.ECOSITE, ")", "")
       End If
    End Sub

  3. #3
    rossi45 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2012
    Posts
    12
    Thanks Steve. With a little modification, that worked well for me.

    I have a further question. Now that I have this check box working, it updates the ECOSITE field. I have another field called "TERR_UNIT". I have the TERR_UNIT field programmed to change anytime the ECOSITE field changes (The TERR_UNIT field is populated by concatenating the ECOSITE field and another field)

    I use a combo box to change the values in the ECOSITE field. When I use the combo box, the TERR_UNIT will update no problem. When I use the check box to modify the ECOSITE field, the TERR_UNIT doesn't update. I'm not sure why. In my following code, I have set an After update event and a change event on the ECOSITE combo box. Is there something I am missing?

    My code is:

    Code:
    Private Sub ECOSITE_Change()
    Me.TERR_UNIT = Me.SMU & "-" & Me.ECOSITE
    End Sub
    
    Private Sub ECOSITE_AfterUpdate()
    Me.TERR_UNIT = Me.SMU & "-" & Me.ECOSITE
    End Sub
    
    Private Sub TERR_UNIT_AfterUpdate()
    Call ECOSITE_AfterUpdate
    Call SMU_AfterUpdate
    Call ECOSITE_Change
    End Sub
    Thanks,
    Mike

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access Programming issue i think???
    By whitey in forum Programming
    Replies: 3
    Last Post: 01-03-2012, 01:15 PM
  2. New to programming in MS access 2007...
    By DarrenReeder in forum Programming
    Replies: 5
    Last Post: 12-05-2010, 01:03 PM
  3. New to Access programming
    By pushpm in forum Programming
    Replies: 1
    Last Post: 02-20-2009, 03:03 PM
  4. Programming Language like Access
    By cwf in forum Programming
    Replies: 2
    Last Post: 05-17-2008, 03:02 AM
  5. Access Programming and Access Data Page
    By frmdread67 in forum Programming
    Replies: 0
    Last Post: 03-19-2008, 03:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums