Results 1 to 8 of 8
  1. #1
    Alaska1 is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Oct 2010
    Posts
    55

    Populating another field based on a checkbox

    I have two fields. One is a checkbox and the other is a text field. when the checkbox is checked I want the other field to populate with text.

    Field Names
    DataEntry
    PayrollErrorOccuredCheck - Check box field

    Once the checkbox field is checked, I need the text box to be populated with payroll error occured.



    What is the best way to do this?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I would hope both of these controls are not also bound to fields in the same table. That would be redundant and unnecessary. You can place anything you want in the TextBox using code in the AfterUpdate event of the CheckBox. Since a CheckBox is a toggle, what do you want to happen if it is clicked twice thereby unchecking the CheckBox?

  3. #3
    Alaska1 is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Oct 2010
    Posts
    55
    Quote Originally Posted by RuralGuy View Post
    I would hope both of these controls are not also bound to fields in the same table. That would be redundant and unnecessary. You can place anything you want in the TextBox using code in the AfterUpdate event of the CheckBox. Since a CheckBox is a toggle, what do you want to happen if it is clicked twice thereby unchecking the CheckBox?
    I have the a field for the Check box and a field for Pay Error Occured in a table. If clicked twice I would like the text to be cleared.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    As I said, these fields are redundant so only one is necessary but here's code for the Click event of your CheckBox:
    Code:
    Private Sub chkBox_Click()
    If Me.chkBox Then
        Me.txtBox = "Payroll error occured"
    Else
        Me.txtBox = ""
    End If
    End Sub
    You of course need to use your names for the chkBox and txtBox.

  5. #5
    Alaska1 is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Oct 2010
    Posts
    55
    Quote Originally Posted by RuralGuy View Post
    As I said, these fields are redundant so only one is necessary but here's code for the Click event of your CheckBox:
    Code:
    Private Sub chkBox_Click()
    If Me.chkBox Then
        Me.txtBox = "Payroll error occured"
    Else
        Me.txtBox = ""
    End If
    End Sub
    You of course need to use your names for the chkBox and txtBox.

    Thank you. The code worked. Appreciate your help.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Did you want to go ahead and use the Thread tool and mark this thread as Solved?

  7. #7
    Alaska1 is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Oct 2010
    Posts
    55
    Quote Originally Posted by RuralGuy View Post
    Did you want to go ahead and use the Thread tool and mark this thread as Solved?

    Thank you! I marked it solved

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Thank you. Say hi to Sarah for me.

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

Similar Threads

  1. Populating attachment field based on text box
    By justinwright in forum Forms
    Replies: 16
    Last Post: 09-22-2010, 08:38 AM
  2. populating value of one field to another
    By jzacharias in forum Database Design
    Replies: 2
    Last Post: 09-08-2010, 02:39 PM
  3. Automatic checkbox based on value entered in form
    By w00tage19 in forum Database Design
    Replies: 2
    Last Post: 07-12-2010, 04:20 AM
  4. Replies: 3
    Last Post: 06-29-2010, 12:08 PM
  5. Make entries uneditable based on checkbox
    By acehowell in forum Programming
    Replies: 1
    Last Post: 04-19-2007, 07:54 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