I have a combo box to select if a person is working in a region or if they are terminated
and i have a check box for active or not
what i would like to do is have the check box unchecked if they are terminated and check for the other 4 regions
I have a combo box to select if a person is working in a region or if they are terminated
and i have a check box for active or not
what i would like to do is have the check box unchecked if they are terminated and check for the other 4 regions
Shouldn't be too difficult.
What do you have as the Row Source property of the combo?
If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
Bob Fitzpatrick
You can put a formula in the checkbox control source. If you are talking about a multi select combo, you can probably write some code but not enough info to suggest anything
a table with
Regions NE, ME, SE, MW, & Terminated
the combo box has this code, as is also shows / hides a 2 date fields
Private Sub Region_AfterUpdate()
UpdateAgent
Select Case Me.Region
Case "1"
Me.HireDate.Visible = True
Me.TerminationDate.Visible = False
Case "2"
Me.HireDate.Visible = True
Me.TerminationDate.Visible = False
Case "3"
Me.HireDate.Visible = True
Me.TerminationDate.Visible = False
Case "4"
Me.HireDate.Visible = True
Me.TerminationDate.Visible = False
Case "5"
Me.HireDate.Visible = False
Me.TerminationDate.Visible = True
End Select
End Sub
as the control source expression.Code:=[TerminationDate] Is Null
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
For this to work, Region must be an option group control.
You can simplify your code. Also remove the quotes, as value is numeric.
Code:Select Case Me.Region.Value Case 1, 2, 3, 4 Me.HireDate.Visible = True Me.TerminationDate.Visible = False Case 5 Me.HireDate.Visible = False Me.TerminationDate.Visible = True End Select
Why would Region have to be an OptionGroup?
Include number field in combobox RowSource.
Assuming there is an ID field with values 1 thru 5: SELECT ID, Region FROM Regions;
Since code shows Region with numeric values, my guess is that is the setup.
Or use Region text values in code.
A combo could be multi-select only if bound to a multi-value field. Hope that's not the case.
Even simpler:
With Me
.HireDate.Visible = .Region <> 5
.TerminationDate.Visible = .Region = 5
End With
Or in place of 5 use "Terminated".
Use Welshgasman's expression for checkbox ControlSource: =[TerminationDate] Is Null
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.
For this to work, Region must be an option group control.
You can simplify your code. Also remove the quotes, as value is numeric.
Code:Select Case Me.Region.Value Case 1, 2, 3, 4 Me.HireDate.Visible = True Me.TerminationDate.Visible = False Case 5 Me.HireDate.Visible = False Me.TerminationDate.Visible = True End Select
this is a little better then my current code. and look nice, but what I'm trying to do - is have a check box set to false if option 5 is selected and true if 1,2,3,4 are selected
Did you see posts 7 and 9? Checkbox need not be dependent on combobox.
Until there is a value in TerminationDate, checkbox should be True.
Really don't need "Terminated" value for Region. This is actually redundant because of TerminationDate field. Could leave with the last assigned region or Null. Code could change Region value when a TerminationDate is entered, even to set field to "Terminated". Not reliant on user to select "Terminated" in combobox.
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.
Can you post a copy of your db
If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
Bob Fitzpatrick
Did you see posts 7 and 9? Checkbox need not be dependent on combobox.
Until there is a value in TerminationDate, checkbox should be True.
Really don't need "Terminated" value for Region. This is actually redundant because of TerminationDate field. Could leave with the last assigned region or Null. Code could change Region value when a TerminationDate is entered, even to set field to "Terminated". Not reliant on user to select "Terminated" in combobox.
I'm kind of new to Access and don't understand some what was posted.
But i think i would need the option 5 terminated as that is how i show the termination date field or the Hire date field
What you show has nothing to do with that checkbox being set or not.
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
"Terminated" value for Region field is not necessary for setting Visibility of other controls but I agree it does simplify code and is user-friendly.
And yes, I was on wrong track about using code behind TransactionDate to set value of Region. Making TransactionDate available is dependent on value in combobox. User HAS to make an explicit decision.
However, the code I showed is simplest and would work with your current setup.
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.