?
Solved

Binding One DB Field, To Multiple Controls (50 Points)

Posted on 2004-03-24
3
Medium Priority
?
249 Views
Last Modified: 2010-04-17
In Visual Basic.Net: I have an Access DB, and i want to Bind a Phone Field Stored As XXX XXX XXXX no spaces. I want to bind it to 3 sperate text boxes without using an invisable intermediate textbox. is this possible? a small code snippet would also be appreciated if possible. Thanks
0
Comment
Question by:RHopkinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:pamboo
ID: 10674958
What is the type of  Phone Field ?  Number or Text
0
 
LVL 3

Accepted Solution

by:
pamboo earned 200 total points
ID: 10675228
I suggest it might be a Text field since number type cannt hold large values (10 digit values) .

Considering u have declared the phone field as text , just try the below .

U bind all the 3 textboxex to the same field

Say dt is ur DataTable

Me.TextBox1.DataBindings.add("Text",dt,"Phone_Field")
Me.TextBox2.DataBindings.add("Text",dt,"Phone_Field")
Me.TextBox3.DataBindings.add("Text",dt,"Phone_Field")

In the TextChanged event of above 3 textbox do the below

'First text box should contain the digits 8 to 10
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

 If  Me.TextBox1.Text <> vbNullString Then

  If Me.TextBox1.Text.Length > 7 then
    Me.TextBox1.Text = Mid(Me.TextBox1.Text,1,Me.TextBox1.Text.Length-7)
  else
    Me.TextBox1.Text = VbNullString ' Or  Me.TextBox1.Text = "000"
  End If

 End If

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

 If  Me.TextBox2.Text <> vbNullString Then

  If TextBox2.Text.Length <= 4 then
     Me.TextBox2.Text = VbNullString ' Or  Me.TextBox1.Text = "000"
  If TextBox2.Text.Length <= 7 and TextBox2.Text.Length >= 5 then
     Me.TextBox2.Text = Mid(Me.TextBox2.Text,1,Me.TextBox1.Text.Length-4)
  Else  If TextBox2.Text.Length > 7
     Me.TextBox2.Text = Mid(Me.TextBox2.Text,Me.TextBox1.Text.Length-6,3)
 End If

End Sub

Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
 If  Me.TextBox3.Text <> vbNullString Then
  If TextBox3.Text.Length > 4 then
     Me.TextBox3.Text = Mid(Me.TextBox3.Text,Me.TextBox3.Text.Length-3)
 End If
End Sub

- Rajan
0
 

Author Comment

by:RHopkinson
ID: 10680217
Thanks, Works Great!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question