Silly question, really, but did not find a single example of exactly how to do this. How to change a textbox to handle numbers & dates no problem, but how to change it back to text: not one explicit example!
So, here's the problem:
I have a form (not bound) with a 5-option group and 2 textboxes (not bound). If one of the first three options is picked, nothing should change, and the user should be able to input text. When one of the last two options is picked, then the user should be able to pick a date.
Code in the AfterUpdate:
Code:
Select Case Me.optgrpZoeken.Value
Case 1
Me.txtZoeken1.Format = "text"
Me.txtZoeken1.Enabled = True
Me.txtZoeken2.Format = "text"
Me.txtZoeken2.Enabled = False
Case 2
Me.txtZoeken1.Format = "text"
Me.txtZoeken1.Enabled = True
Me.txtZoeken2.Format = "text"
Me.txtZoeken2.Enabled = False
Case 3
Me.txtZoeken1.Format = "text"
Me.txtZoeken1.Enabled = True
Me.txtZoeken2.Format = "text"
Me.txtZoeken2.Enabled = False
Case 4
Me.txtZoeken1.Format = "short date"
Me.txtZoeken1.Enabled = True
Me.txtZoeken2.Format = "short date"
Me.txtZoeken2.Enabled = True
Case 5
Me.txtZoeken1.Format = "short date"
Me.txtZoeken1.Enabled = True
Me.txtZoeken2.Format = "short date"
Me.txtZoeken2.Enabled = True
End Select
The reason I want to put the format to text is that when a user picks one of the last two, but changes his/her mind, the textbox changes back to text instead of the date-picker.
Problem now is that when I open the form (default = 1), the textbox is "text" (clicking in the box: cursor on the left). I then pick option 2 (should still be text), click inside the box and see the cursor on the right When I try to type text, the damn thing gives me an error, saying that I'm trying to type text in a number field Nowhere did I change the properties of the textbox to a number, not through VBA, not through control properties, and also means that the syntax of the format = "text" is probably wrong. So I'm a bit at a loss as to why this would/could even happen...
Anybody any clue?
TIA,
James