Results 1 to 7 of 7
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185

    Event Procedures


    I have all these event procedures that I have created for a form with Checkboxes.
    Now, I need to do a little adjusting...
    If I check a box, and the event procedure, that runs on the AfterUpdate event, can I somehow get the code to run the AfterUpdate events I have for the other check boxes?
    For instance, I click Checkbox 1, I want it to run the AfterUpdate event that I coded to 10 other check boxes. If I click Check box 4, I only want it to run the code for the 6 of the check boxes.

  2. #2
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by jlgray0127 View Post
    I have all these event procedures that I have created for a form with Checkboxes.
    Now, I need to do a little adjusting...
    If I check a box, and the event procedure, that runs on the AfterUpdate event, can I somehow get the code to run the AfterUpdate events I have for the other check boxes?
    For instance, I click Checkbox 1, I want it to run the AfterUpdate event that I coded to 10 other check boxes. If I click Check box 4, I only want it to run the code for the 6 of the check boxes.
    Yes, you can just refer to the name of the code:

    Private Sub CheckBox1_AfterUpdate()
    CheckBox2_AfterUpdate
    CheckBox3_AfterUpdate
    CheckBox4_AfterUpdate
    End Sub

    This code runs the code for checkbox 2-3 after the update event

  3. #3
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185
    You Rock!!! Thanks!

  4. #4
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185
    Uh... After I applied this to the other boxes, Slowed the database way down... takes about 6 minutes to run, and only runs for checkbox 2.
    Here's what I'm doing...
    I have a row of check boxes. Under the checkboxes, there is a row of textboxes. If the checkbox above the text boxes is clicked, it hides the text boxes. I want it so when I click the first box, it will run the code to hide all text boxes after... so, check box 2, hides all the text box rows that follow... if I put the same code for each check box, to hide the text boxes that follow... won't it try to inadvertly hide everything over and over again... each checkbox references the new code, so if I click box.. below is sample for box 1 and box 2... There are a total of 20 checkboxes.

    Private Sub Check225_AfterUpdate()
    Check280_AfterUpdate
    Check282_AfterUpdate
    Check284_AfterUpdate
    Check286_AfterUpdate
    Check288_AfterUpdate
    Check290_AfterUpdate
    Check292_AfterUpdate
    Check294_AfterUpdate
    Check296_AfterUpdate
    Check298_AfterUpdate
    Check300_AfterUpdate
    Check527_AfterUpdate
    Check488_AfterUpdate
    Check489_AfterUpdate
    Check490_AfterUpdate
    Check491_AfterUpdate
    Check524_AfterUpdate
    Check525_AfterUpdate
    Check526_AfterUpdate

    Private Sub Check280_AfterUpdate()
    Check282_AfterUpdate
    Check284_AfterUpdate
    Check286_AfterUpdate
    Check288_AfterUpdate
    Check290_AfterUpdate
    Check292_AfterUpdate
    Check294_AfterUpdate
    Check296_AfterUpdate
    Check298_AfterUpdate
    Check300_AfterUpdate
    Check527_AfterUpdate
    Check488_AfterUpdate
    Check489_AfterUpdate
    Check490_AfterUpdate
    Check491_AfterUpdate
    Check524_AfterUpdate
    Check525_AfterUpdate
    Check526_AfterUpdate

  5. #5
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by jlgray0127 View Post
    Uh... After I applied this to the other boxes, Slowed the database way down... takes about 6 minutes to run, and only runs for checkbox 2.
    Here's what I'm doing...
    I have a row of check boxes. Under the checkboxes, there is a row of textboxes. If the checkbox above the text boxes is clicked, it hides the text boxes. I want it so when I click the first box, it will run the code to hide all text boxes after... so, check box 2, hides all the text box rows that follow... if I put the same code for each check box, to hide the text boxes that follow... won't it try to inadvertly hide everything over and over again... each checkbox references the new code, so if I click box.. below is sample for box 1 and box 2... There are a total of 20 checkboxes.

    Private Sub Check225_AfterUpdate()
    Check280_AfterUpdate
    Check282_AfterUpdate
    Check284_AfterUpdate
    Check286_AfterUpdate
    Check288_AfterUpdate
    Check290_AfterUpdate
    Check292_AfterUpdate
    Check294_AfterUpdate
    Check296_AfterUpdate
    Check298_AfterUpdate
    Check300_AfterUpdate
    Check527_AfterUpdate
    Check488_AfterUpdate
    Check489_AfterUpdate
    Check490_AfterUpdate
    Check491_AfterUpdate
    Check524_AfterUpdate
    Check525_AfterUpdate
    Check526_AfterUpdate

    Private Sub Check280_AfterUpdate()
    Check282_AfterUpdate
    Check284_AfterUpdate
    Check286_AfterUpdate
    Check288_AfterUpdate
    Check290_AfterUpdate
    Check292_AfterUpdate
    Check294_AfterUpdate
    Check296_AfterUpdate
    Check298_AfterUpdate
    Check300_AfterUpdate
    Check527_AfterUpdate
    Check488_AfterUpdate
    Check489_AfterUpdate
    Check490_AfterUpdate
    Check491_AfterUpdate
    Check524_AfterUpdate
    Check525_AfterUpdate
    Check526_AfterUpdate
    To hide multiple check boxes, I would just write a loop to hide the boxes. First, name your check boxes in sequential order. For example: CheckBox1, CheckBox2, CheckBox3 and so on.

    You then do a loop in your code to hide them:

    Dim X as integer

    For X = 1 to 4 'four total check boxes to hide
    Me("CheckBox" & X).Visible=False
    Next X

  6. #6
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185
    Hmmm... now I'm really confused! LOL... It doesn't take much!
    Can you explain with my code for an example? I really appreciate your patience! Thank you!!!!

  7. #7
    Toyman is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    233
    Quote Originally Posted by Toyman View Post
    To hide multiple check boxes, I would just write a loop to hide the boxes. First, name your check boxes in sequential order. For example: CheckBox1, CheckBox2, CheckBox3 and so on.

    You then do a loop in your code to hide them:

    Dim X as integer

    For X = 1 to 4 'four total check boxes to hide
    Me("CheckBox" & X).Visible=False
    Next X
    If your check boxes are named in sequential order, lets say CheckBox1, CheckBox2, CheckBox3, CheckBox3.
    The code first declears the veriable "X" as an integer

    The Loop starts with defining the range for "X" (For X = 1 to 4)
    As the code begins, "X" takes on the number 1. It then goes to the second line (Me("CheckBox" & X).Visible=False). "Me" refers to your current form or report. You can use "Me.CheckBox1" to refer to CheckBox1. By using "Me()" I can then use the first part of the check box name, "CheckBox" and combine it with the veriable "X" to identify te object as being CheckBox1. The second part of this line then assign the "Visible" setting to False (making it invisible). The next line of code "Next X" simply brings "X" back to the first line of code and assign it the next number from the range and repeat itself. The code will stop once the last value in the range is reached and has completed the rest of the code.

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

Similar Threads

  1. stored procedures failure
    By MrGrinch12 in forum Programming
    Replies: 1
    Last Post: 06-23-2010, 12:54 PM
  2. Event procedures
    By GIS_Guy in forum Forms
    Replies: 1
    Last Post: 05-11-2010, 02:34 PM
  3. Help with functions / procedures
    By curnil in forum Programming
    Replies: 3
    Last Post: 03-09-2010, 05:41 PM
  4. Replies: 21
    Last Post: 06-03-2009, 05:54 PM
  5. Replies: 0
    Last Post: 01-08-2009, 05:49 PM

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