Hi Karen (@Karen Payne MVP ),
Thank you for writing.
This is what I am doing:
- I have an Access Table: tblBMList
- The database contains a query, qryBMList, that sorts the table by LastName, FirstName and also adds a field FirstName & " " & LastName as StudentName for other purposes.
- I dragged qryBMList onto a blank form, frmBMList which then created a BindingNavigator and a DataGridView
- I deleted the DataGridView since I want to view table one record at a time…and since each record contains vast amounts of data and also uses sub-Tables that contain other "transactional" data.
- I then either: A) Dragged individual fields from the Query onto the form, or used the Toolbox for: DateTimePickers, MaskedTextBoxes, CheckBoxes, etc. and then assigned them corresponding fields in tblBMList by using the DataBindings in the Properties window. This is how I created the fields in the TabControl.
- In addition to the MoveFirst, MovePrevious, MoveNext, MoveLast Item buttons in the BindingNavigator, I also added a ToolStripComboBox: cboBMList to jump directly to a specific Student’s record. cboBMList is initialized by using the following code:
Me.cboBMList.ComboBox.DataSource = Me.QryBMListBindingSource Me.cboBMList.ComboBox.DisplayMember = "StudentName" Me.cboBMList.ComboBox.ValueMember = "RecordKey"
I use the Sub QryBMListBindingSource_CurrentChanged to populate the non-Bound fields in the form.
I placed a debugging loop in that Sub to dump out the values of the fields in the TabControl:
Dim tabCurrent As TabPage
Dim ctlCurrent As Control
Debug.Print("Debugging Me.tcParentContacts")
For Each tabCurrent In Me.tcParentContacts.TabPages
Debug.Print($"In: {tabCurrent.Name}")
For Each ctlCurrent In tabCurrent.Controls
Debug.Print($"In: {ctlCurrent.Name}, {ctlCurrent.Text}")
Next
Next
This is what I found:
The only fields that always get printed, are the two fields in the first tab: tabpgCellPhone.
The other fields only get printed if I pre-Select one of the other TabPages before navigating to it (the fields of tabpgCellPhone always get printed regardless of which TabPage is selected.
So, I modified the routine and added two lines of code before the loop:
Dim tabSelected As TabPage
tabSelected = Me.tcParentContacts.SelectedTab
and inserted another line withing the loop:
Me.tcParentContacts.SelectedTab = tabCurrent
and then, one more line after the loop to go back to the originally displayed TabPage:
Me.tcParentContacts.SelectedTab = tabSelected
This had the desired effect of displaying all of the Parent1 and Parent2 information fields.
In addition, I cleaned up some code that was being fired inadvertently when some of the Date fields were being updated by the when the navigation changed, but that had independent TextChanged properties that would update other non-Bound fields in the form. Once I did that, then the Parent information…specifically the Email field problem went away.
So I am left with one question: when I call the sub-Form that does the email inquiry, I do have the code select the Email TabPage in order to get to the Email fields.
Is there any other way of getting to the data…other than: QryBMListBindingSource.Current("<Email Field Name>").ToString ?
Again, thank you for your time in advance.
Paul Goldstein