Results 1 to 3 of 3
  1. #1
    wrkadri is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2012
    Posts
    29

    Exclamation Problem with my checkbox vba code

    Hi all,


    I am working on a database system and I'm using checkboxes.

    Click image for larger version. 

Name:	Checkbox.png 
Views:	14 
Size:	7.2 KB 
ID:	10331

    In the Water treatment part, when I check any of these checkboxes, I get the value true to all records. While it should be True when checked and False when not.
    I'm using this vba code to control it:

    Private Sub Form_Current()
    a = Water_Treatment
    If a - 8 >= 0 Then
    a = a - 8
    Aqua_tablet = True
    Else
    Aqua_tablet = False
    End If
    If a - 4 >= 0 Then
    a = a - 4
    Boiling = True
    Else
    Boiling = False
    End If
    If a - 2 >= 0 Then
    a = a - 2
    Clorination = True
    Else
    Clorination = False
    End If
    If a - 1 >= 0 Then
    a = a - 1
    wFilter = True
    Else
    wFilter = False
    End If
    End Sub

    Private Sub Boiling_AfterUpdate()
    If Boiling = True Then
    Water_Treatment.Value = Water_Treatment.Value + 4
    Else
    Water_Treatment.Value = Water_Treatment.Value - 4

    End If

    End Sub

    Private Sub Clorination_AfterUpdate()
    If Clorination = True Then
    Water_Treatment.Value = Water_Treatment.Value + 2
    Else
    Water_Treatment.Value = Water_Treatment.Value - 2

    End If

    End Sub


    Private Sub Aqua_tablet_AfterUpdate()
    If Aqua_tablet = True Then
    Water_Treatment.Value = Water_Treatment.Value + 8
    Else
    Water_Treatment.Value = Water_Treatment.Value - 8

    End If

    End Sub


    Private Sub wFilter_AfterUpdate()
    If wFilter = True Then
    Water_Treatment.Value = Water_Treatment.Value + 1
    Else
    Water_Treatment.Value = Water_Treatment.Value - 1

    End If

    End Sub




    Can anybody help me with this ?
    Thank you in advance

    Regards,

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,924
    Unbound data controls will show the same value for all records.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    wrkadri is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2012
    Posts
    29
    Thank you for your help. Problem was solved.

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

Similar Threads

  1. Replies: 7
    Last Post: 12-12-2012, 03:14 PM
  2. Code problem
    By sboelitz in forum Programming
    Replies: 1
    Last Post: 06-15-2012, 08:35 AM
  3. Problem with Code
    By jackiea in forum Programming
    Replies: 1
    Last Post: 10-07-2011, 05:59 PM
  4. Code Problem
    By Jeddell in forum Programming
    Replies: 2
    Last Post: 09-29-2011, 06:31 PM
  5. Problem with Code
    By cujee75 in forum Programming
    Replies: 0
    Last Post: 03-10-2006, 02:40 AM

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