Re: Changing Combobox to text box




Hi George
"Why not just set Enable = False and Locked = True? "
Thats a great suggestion except I want my users to have the ability to right
click on a field and do a filter. However now that I think about it I
suppose I could get them used to the 'filter by form' icon.
Thanks again!
Marco

"George Nicholson" wrote:

Why not just set Enable = False and Locked = True? That prevents the
dropdown from functioning but otherwise preserves the appearance of the
control. If you want to hide the dropdown arrow, you can create a small
rectangle the same color as your form background that will cover the arrow
and then toggle it's Visible property as appropriate.

HTH,


"Marco Brilo" <MarcoBrilo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AA43EFAC-6373-4ECD-8380-9028DFB1099D@xxxxxxxxxxxxxxxx
Hi I have a form where users have options buttons to choose betweeen edit
mode and view only mode. When the view mode is chosen, I have a script
that
will disable my combo boxes and hide certain buttons etc, but when they
choose edit mode, they the combo boxes and text boxes become enabled and
unlocked allowing the user to make changes to the data.
So here's my question, how do I change the combo box to a text box when
the
user is in view mode so that they aren't likely to click on the field to
see
a drop down of values, and when they come back to edit mode, change the
text
box to a combo box again. I've pasted code below tha I am currently
using.
Thanks
Marco


'************************************ VIEW DATA
************************************************************

If Me.Mode.Value = 2 Then
Me.DataEntry = False
Me.AllowEdits = False
Me.Search_Area_ID
For Each Control In Form.Controls
'MAIN FORM
With Control
Select Case .ControlType
Case acTextBox
.Visible = True
.Locked = True
.BackStyle = 0
.SpecialEffect = 0
.BorderStyle = 1
.BorderColor = RGB(255, 255, 255)
Case acComboBox
.Visible = True
.Locked = True
.BackStyle = 0
.SpecialEffect = 0
.BorderStyle = 1
.BorderColor = RGB(255, 255, 255)
Case acCommandButton
.Visible = True
End Select
End With
Next Control


Forms!Field_Data.Form!OBSERVER.Visible = True
For Each Control In
Forms!Field_Data.Form!OBSERVER.Form.Controls
'OBSERVER SUBFORM
With Control
Select Case .ControlType
Case acTextBox
.Locked = True
.BackStyle = 0
.SpecialEffect = 0
.BorderStyle = 1
.BorderColor = RGB(255, 255, 255)
Case acComboBox
.Locked = True
.BackStyle = 0
.SpecialEffect = 0
.BorderStyle = 1
.BorderColor = RGB(255, 255, 255)
End Select
End With
Next Control
Forms!Field_Data.Form!OBSERVATION.Visible = True
For Each Control In
Forms!Field_Data.Form!OBSERVATION.Form.Controls 'OBSERVATION SUBFORM
With Control
Select Case .ControlType
Case acTextBox
.Locked = True
.BackStyle = 0
.SpecialEffect = 0
.BorderStyle = 1
.BorderColor = RGB(255, 255, 255)
Case acComboBox
.Locked = True
.BackStyle = 0
.SpecialEffect = 0
.BorderStyle = 1
.BorderColor = RGB(255, 255, 255)
End Select
End With
Next Control


Me.AllowAdditions = False
Me.Cmd_Create_Table.Visible = False
Me.Option28.Enabled = True
Me.cmd_Open_Select_Record.Visible = False
Me.NavigationButtons = True
Me.cltAddNewRecord.Visible = False


'************************************ EDIT DATA
************************************************************


ElseIf Me.Mode.Value = 1 Then
lngRecToEdit = Me.Survey_ID.Value
Me.DataEntry = False

For Each Control In Form.Controls
'MAIN FORM
With Control
Select Case .ControlType
Case acTextBox
.Visible = True
.Locked = False
.BackColor = RGB(255, 255, 255)
.BackStyle = 1
.SpecialEffect = 2

Case acComboBox
.Visible = True
.Locked = False
.BackColor = RGB(255, 255, 255)
.BackStyle = 1
.SpecialEffect = 2
Case acCommandButton
.Visible = True
End Select
End With
Next Control


Forms!Field_Data.Form!OBSERVER.Visible = True
For Each Control In
Forms!Field_Data.Form!OBSERVER.Form.Controls
'OBSERVER SUBFORM
With Control
Select Case .ControlType
Case acTextBox
.Locked = False
.BackColor = RGB(255, 255, 255)
.BackStyle = 1
.SpecialEffect = 2

Case acComboBox
.Locked = False
.BackColor = RGB(255, 255, 255)
.BackStyle = 1
.SpecialEffect = 2
End Select
End With
Next Control

Forms!Field_Data.Form!OBSERVATION.Visible = True
For Each Control In
Forms!Field_Data.Form!OBSERVATION.Form.Controls 'OBSERVATION SUBFORM
With Control
Select Case .ControlType
Case acTextBox
.Locked = False
.BackColor = RGB(255, 255, 255)
.BackStyle = 1
.SpecialEffect = 2

Case acComboBox
.Locked = False
.BackColor = RGB(255, 255, 255)
.BackStyle = 1
.SpecialEffect = 2
End Select
End With
Next Control

Me.NavigationButtons = False
Me.cltAddNewRecord.Visible = False
Me.cmd_Open_Select_Record.Visible = True
Me.Cmd_Create_Table.Visible = True
Me.Filter = "SURVEY_ID = " & lngRecToEdit
Me.FilterOn = True





.