access data connection to 2 tables

Johnnh

Member
Joined
May 5, 2006
Messages
6
Programming Experience
Beginner
Hello

I have a dataform attached to an access database with two tables. I am showing details on 2 text boxes from one table when i press the load button. But need to show details from the second table in the same text boxes when i press a second load button on the same form.

Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "address", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("address1", "address1"), New System.Data.Common.DataColumnMapping("address2", "address2")})})

Can i specify the data adapter and table mapping as strings so the
adapter looks at the other second table when the command button is pressed.

I did try this code (below) but it still holds the data from the first table and does not display it correctly.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
editaddress1.Text = ""
editaddress2.Text = ""
Try
Me.LoadDataSet()
OleDbDataAdapter1.Fill(objpersonaldetails)
editaddress1.DataBindings.Add("text", objpersonaldetails, "name.surname")
editaddress2.DataBindings.Add("text", objpersonaldetails, "name.forename")

Catch eLoad As System.Exception

System.Windows.Forms.MessageBox.Show(eLoad.Message)
End Try
Me.objpersonaldetails_PositionChanged()
End Sub

End Class


The tables in question have two fields each the first table is the
adress1 and address2
forename and surname

Is this possible or should i create a new dataform for each table as i cannot have the same information on the form at the same time.

Any help most welcome.

Thanks j


j
 
Just wanted to welcome you as user of the forums, Johnnh! Nice username :)
 
Back
Top