Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Mask and Format Confusion

Status
Not open for further replies.

njwcad

Technical User
Oct 16, 2002
156
GB
Can anyone Help
I have the following problem;
I have a form sourced from an underlying table with two controls which, for simplicity, I will call control A and control B. I am defining an input mask using the set value on a macro that says.
If Control A = "London" then set [Control A].[Input Mask] to
">LL-L-L-L/00"
If Control A = "New York" then set [Control A].[Input Mask] to
">LL-L0-L-L/00"
This seems to work okay. However I would also like to set a format that represents the input mask so when sourced in another form the display format is the same as the input mask. I have tried variations but can't seem to get it right. For example
If Control A = "London" then set [Control A].[Format] to
"@@-@-@-@/@@"
If Control A = "New York" then set [Control A].[Format] to
"@@-@@-@-@/@@"
I realise that this might be achieved in code, or maybe I can still resolve this through a macro, as I'm a complete novice regarding code and wouldn't know where to start. Any help you can give would really be appreciated

Thanks in advance

 
Hi njwcad,
Well, you have to start using code some day, so it might as well be today...
In the afterupdate-event (look in the event-list of the control) of your combox for the city's you can put the following code. I use CityNameID's instead of the full name, that is a bit easier.

Code:
Private Sub CityNameID_AfterUpdate()
    If Me.CityNameID = 1 Then 'London
        Me.ControlA.InputMask = ">LL-L-L-L/00"
        Me.ControlA.Format = "@@-@-@-@/@@"
    End If
    
    If Me.CityNameID = 2 Then 'New York
        Me.ControlA.InputMask = ">LL-L0-L-L/00"
        Me.ControlA.Format = "@@-@@-@-@/@@"
    End If
End Sub

Pampers [afro]
Just let it go...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top