Results 1 to 3 of 3
  1. #1
    Join Date
    May 2003
    Location
    Pgh
    Posts
    8

    Lightbulb Unanswered: Checkbox Validation & Auto Populating

    Here the situation:
    I have two checkboxs that are in the same table.

    1)
    Checkbox1 - when checked I want it to change two other fields in the current record to 0. I have gotten to this from trial and error.

    Private Sub Vul_Needed_Click()
    DoCmd.RunSQL "UPDATE [tblView] set [Total_Devices]=0, [Patched_Devices]=0"
    End Sub

    But the problem is that this changes [Total_Devices] and [Patched_Devices] to 0 in the entire table.

    How do I change just [Total_Devices] and [Patched_Devices] on the current record.

    2)
    Checkbox2 - when checked I want to check to make sure the [Total_Devices] - [Patched_Devices] = 0 in the current record, if not then display and error message. I have tired this using a validation rule in the properties box but it Access doesn't like that. Is there another way to do this check when the check box is checked?


    Please Advise!

  2. #2
    Join Date
    May 2002
    Location
    Atlanta, GA
    Posts
    117
    Hey,

    I would use the On_Click events of the check boxes. In this you can run your SQL statements threw VB.

    Private Sub CheckBox_Click()
    IF Me.CheckBox = True Then
    DoCmd.RunSQL = "UPDATE Table SET Field WHERE Field = "Something":
    End If
    End Sub

    This will run the query if the user changes the value of the checkbox to true. Does this help???

    Kal

  3. #3
    Join Date
    May 2003
    Location
    Pgh
    Posts
    8
    That SQL statement was like the one that I sent. It updates the entire table. I need to just update the current record. I have two postings which are basically the same thing. Any suggestions on:
    2)
    Checkbox2 - when checked I want to check to make sure the [Total_Devices] - [Patched_Devices] = 0 in the current record, if not then display and error message. I have tired this using a validation rule in the properties box but it Access doesn't like that. Is there another way to do this check when the check box is checked?

    Please Advise on both issues, if you can.

    Thanks for the help it is greatly appreciated.

    Originally posted by kpalmer
    Hey,

    I would use the On_Click events of the check boxes. In this you can run your SQL statements threw VB.

    Private Sub CheckBox_Click()
    IF Me.CheckBox = True Then
    DoCmd.RunSQL = "UPDATE Table SET Field WHERE Field = "Something":
    End If
    End Sub

    This will run the query if the user changes the value of the checkbox to true. Does this help???

    Kal

Posting Permissions

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