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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show DB data in MaksEdBox

Status
Not open for further replies.

Andrzejek

Programmer
Jan 10, 2006
8,486
5
38
US
Trying to show data from DB in MaskEdBox - phone number.

Following steps from MaskedBox for Phone I have this code:

Code:
With MyRecordSet
    ...
    mebPhone.Mask = ""        [green]'1[/green]
    mebPhone.Text = ""        [green]'2[/green]
    mebPhone.Text = !SUPERV_PHONE.Value    [green]'3[/green]
    mebPhone.Mask = "(###)###-####"        [green]'4[/green]
    ....
End With

Line 1 - should eliminate Mask, I guess, but after executing this line, box shows [tt] (___) ___-____[/tt] (initial mask)
Line 2 - box shows empty. Great!
Line 3 - box shows [tt]1235551212[/tt], data from DB, great!
Line 4 - data gone, box shows mask: [tt] (___) ___-____[/tt], no data :-(

So what should I do to populate MaskEdBox and show the phone as (123) 555-1212?

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
How about something like;

Code:
MaskEdBox1.Format = ""       '1
MaskEdBox1.Text = ""        '2
    
MaskEdBox1.Format = "(###)###-####"  '3
MaskEdBox1.Text = "1235551212"  '4
 
Run-time error '380': Invalid Property Value :-(

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Sorry Andy but I get no error when I run the code from a command button click. The required format is shown when the MaskedEditBox (MEB) does not have focus, when it does have focus the plain unformatted number is shown. Tested (and re-tested) using a new Form with a new Command button, a new MEB and a new TextBox; the latter allowing the MEB to loose focus without having the click the command button again.
 
This seams to work for me:

Code:
With MyRecordSet
    ...
    mebPhone.Mask = ""
    [green]'mebPhone.Text = ""[/green]
    mebPhone.Text = [blue]Format([/blue]!SUPERV_PHONE.Value[blue], "(###)###-####")[/blue]
    mebPhone.Mask = "(###)###-####"
    ....
End With

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
HughLerwill,
Your answer from 5 Nov 16 11:00 works if no Mask is established for the MaskEdBox, but I like to keep the Mask so user will know I need the phone number in certain format - which Mask demands from user.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top