Fred Webb
asked on
Programmatically change a controls format property
I have a search form that has 2 unbound controls a combo box (cboSearchField) and a text box (txtSearchString) the combo box is used to select the search criteria and the Text box is the search string, one of the criteria is a date (CountDate). What I want to do is programmatically change the controls format property to “Short Date” when the combo box contains CountDate, so that the calendar displays, and reset it back for non-date searches. BTW this is Access 2007.
What other search criteria do you have - numbers, boolean, strings?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Text, Yes/No
ASKER
pdebaets,
The calender does appear, with unbound controls, I will test your code.
The calender does appear, with unbound controls, I will test your code.
ASKER
pdebaets
I tried putting the code where you suggested in the AfterUpdate and OnCurrent events but it didn't work, so I added it to the GotFocus event of txtSearchString and added .Value to cboSearchField of your code and that seemed to work. Thanks for the help.
I tried putting the code where you suggested in the AfterUpdate and OnCurrent events but it didn't work, so I added it to the GotFocus event of txtSearchString and added .Value to cboSearchField of your code and that seemed to work. Thanks for the help.
Private Sub txtSearchString_GotFocus()
If cboSearchField.Value = "CountDate" Then
txtSearchString.Format = "Short Date"
Else
txtSearchString.Format = ""
End If
End Sub
ASKER
See my last post for further instructions