Dependant textbox format

G

Gabe

I'm really new at this, and I was hoping you could help. How do I make the
format of one textbox dependant of the value selected in a different combobox
within the same form.

For example, If the user selects "Group1" from the combobox, then the
textbox format will be set as numbers. If the user selects "Group2" from the
combobox, then the textbox format will be set as dates. I'm using Access 2003.

Thanks,
~Gabe
 
S

Scott Whetsell, A.S. - WVSP

This can be accomplished using the AfterUpdate event of the combobox.
Something similar to:

Private Sub cboGroupSelect_AfterUpdate()
If Me.cboGroupSelect = "Group1" Then
Me.txtTextBox.InputMask = "99999999;;_"
Else: Me.txtTextBox.InputMask = "00-00-0000;0;_"
End If
End Sub

Substitute cboGroupSelect for the name of your combobox and txtTextBox for
the name of your text box. You can change the masks to enforce whatever type
of data you want the user to input.
 
G

Gabe

Wow, yes that worked great, but how would I do numbers with auto decimals if
Group1 is selected? If a user selects Group1 from the combobox then the
textbox format will be set as numbers with auto decimals. So the user can now
type in 1.23, or 11.23, or 111.23 within the textbox.
 
S

Scott Whetsell, A.S. - WVSP

If you are going to require the decimal, add .00 to the mask, otherwise use
..99.

It should look like: 999999.00

Have however many numbers you want on each side of the decimal for your
application. 9s indicate an optional entry, 0s indicate mandatory entry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top