|
-
Feb 26th, 2009, 04:47 AM
#1
Thread Starter
Lively Member
[Resolved] [2008] Databindings Problem
I know $10 isn't much, but I'm a student and it's my college project we're talking about. It's a problem that's preventing me from continuing work on it. Even my computing teacher is stumped, so he's given me the go-ahead to do this. Typically, as a student, there's barely a dime in my bank account so I can't offer much more.
This is the form I'm having problems with. As you can see I've created a tab interface which is working. There are five text boxes on it which are binded to the Staff table in the database. When the tab is changed, the binding is changed to a new field. However, unfortunately, when a new record is selected, the data bindings do not update, and instead, the first record is always being used. We suspect the problem may be coming from the fact that there is code to unbind from the text box and rebind it again. This is the code I'm talking about...
Code:
Private Sub TabCheck()
If TabState = 1 Then
pnlTabs.BackgroundImage = My.Resources.tabs1
txtBox1.Visible = True
txtBox2.Visible = True
txtBox3.Visible = True
txtBox4.Visible = False
txtBox5.Visible = False
lblBox1.Text = "Colleague ID"
lblBox2.Text = "Colleague Role"
lblBox3.Text = "Colleague Access Level"
lblBox4.Text = ""
lblBox5.Text = ""
Me.txtBox1.DataBindings.Remove(Me.txtBox1.DataBindings("Text"))
Me.txtBox2.DataBindings.Remove(Me.txtBox2.DataBindings("Text"))
Me.txtBox3.DataBindings.Remove(Me.txtBox3.DataBindings("Text"))
Me.txtBox1.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueID"))
Me.txtBox2.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueRole"))
Me.txtBox3.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueAccessLevel"))
StaffBindingSource.Position += 1
Else
If TabState = 2 Then
pnlTabs.BackgroundImage = My.Resources.tabs2
txtBox1.Visible = True
txtBox2.Visible = True
txtBox3.Visible = True
txtBox4.Visible = True
txtBox5.Visible = True
lblBox1.Text = "Colleague Surname"
lblBox2.Text = "Colleague First Name"
lblBox3.Text = "Date of Birth"
lblBox4.Text = "Home Phone Number"
lblBox5.Text = "Mobile Number"
Me.txtBox1.DataBindings.Remove(Me.txtBox1.DataBindings("Text"))
Me.txtBox2.DataBindings.Remove(Me.txtBox2.DataBindings("Text"))
Me.txtBox3.DataBindings.Remove(Me.txtBox3.DataBindings("Text"))
Me.txtBox4.DataBindings.Remove(Me.txtBox4.DataBindings("Text"))
Me.txtBox5.DataBindings.Remove(Me.txtBox5.DataBindings("Text"))
Me.txtBox1.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueSurname"))
Me.txtBox2.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueFirstNames"))
Me.txtBox3.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueDOB"))
Me.txtBox4.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleaguePhoneNumber"))
Me.txtBox5.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueMobileNumber"))
Else
If TabState = 3 Then
pnlTabs.BackgroundImage = My.Resources.tabs3
txtBox1.Visible = True
txtBox2.Visible = True
txtBox3.Visible = True
txtBox4.Visible = False
txtBox5.Visible = False
lblBox1.Text = "Colleague Post Code"
lblBox2.Text = "Colleague City"
lblBox3.Text = "Colleague Street"
lblBox4.Text = ""
lblBox5.Text = ""
Me.txtBox1.DataBindings.Remove(Me.txtBox1.DataBindings("Text"))
Me.txtBox2.DataBindings.Remove(Me.txtBox2.DataBindings("Text"))
Me.txtBox3.DataBindings.Remove(Me.txtBox3.DataBindings("Text"))
Me.txtBox1.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleaguePostCode"))
Me.txtBox2.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueCity"))
Me.txtBox3.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueStreet"))
Else
If TabState = 4 Then
pnlTabs.BackgroundImage = My.Resources.tabs4
txtBox1.Visible = True
txtBox2.Visible = True
txtBox3.Visible = True
txtBox4.Visible = True
txtBox5.Visible = True
lblBox1.Text = "Hours Per Week"
lblBox2.Text = "Hourly Pay Rate"
lblBox3.Text = "Date Joined Company"
lblBox4.Text = "Currently on Holiday?"
lblBox5.Text = "Next Due Holiday Date"
Me.txtBox1.DataBindings.Remove(Me.txtBox1.DataBindings("Text"))
Me.txtBox2.DataBindings.Remove(Me.txtBox2.DataBindings("Text"))
Me.txtBox3.DataBindings.Remove(Me.txtBox3.DataBindings("Text"))
Me.txtBox4.DataBindings.Remove(Me.txtBox4.DataBindings("Text"))
Me.txtBox5.DataBindings.Remove(Me.txtBox5.DataBindings("Text"))
Me.txtBox1.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueHoursPerWeek"))
Me.txtBox2.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueHourlyRate"))
Me.txtBox3.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueDateJoined"))
Me.txtBox4.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueOnHoliday"))
Me.txtBox5.DataBindings.Add(New Binding("Text", UberData.Staff, "ColleagueUpcomingHoliday"))
End If
End If
End If
End If
End Sub
I'm guessing you'd prefer to view the code, so if you're interested please reply and I will provide you with it. Thanks for reading.
Edit: I forgot to say. Payment will be made via PayPal.
Last edited by ShaunC193; Nov 18th, 2011 at 10:03 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|