I am new to VB. I have a form with three ACCESS tables linked in a
1-many-many relationship. I am using command buttons instead of data
controls for navigation. What I would like to do is to have the secondary
and tertiary table records move when I an moving through the primary table
record. I would also need to have the tertiary table record move in
accordance with movement in the secondary table records. How do I
accomplish that?
Option Explicit
Dim dbCurrent As Database
Dim aSQL, bSQL, cSQL As String
Dim HoldPrim, HoldSec As Integer
Dim aRS, bRS, cRS As Recordset
Dim K0, L0, L1 As Integer
Private Sub datMaster_Click()
''''primary table navigation
Text1(0).Text = aRS.Fields(0).Value
Text1(1).Text = aRS.Fields(1).Value
Text1(2).Text = aRS.Fields(2).Value
Text1(3).Text = aRS.Fields(3).Value
Text1(4).Text = aRS.Fields(4).Value
Text1(5).Text = aRS.Fields(5).Value
Text1(6).Text = aRS.Fields(6).Value
Text1(7).Text = aRS.Fields(7).Value
With aRS
.MoveNext
End With
End Sub
Private Sub datSecondary_Click()
''''secondary table navigation
Text2(0).Text = bRS.Fields(0).Value
Text2(1).Text = bRS.Fields(1).Value
Text2(2).Text = bRS.Fields(2).Value
Text2(3).Text = bRS.Fields(3).Value
With bRS
.MoveNext
End With
End Sub
Private Sub datTertiary_Click()
'''''''''tertiary table navigation
Text3(0).Text = cRS.Fields(0).Value
Text3(1).Text = cRS.Fields(1).Value
Text3(2).Text = cRS.Fields(2).Value
With cRS
.MoveNext
End With
End Sub
Private Sub Form_Load()
'''acquire data from master table
Set dbCurrent = OpenDatabase(App.Path + "\MULTITABLES.MDB")
aSQL = "select * from AGEPRIM"
Set aRS = dbCurrent.OpenRecordset(aSQL)
K0 = aRS.Fields(0).Value
Text1(0).Text = aRS.Fields(0).Value
Text1(1).Text = aRS.Fields(1).Value
Text1(2).Text = aRS.Fields(2).Value
Text1(3).Text = aRS.Fields(3).Value
Text1(4).Text = aRS.Fields(4).Value
Text1(5).Text = aRS.Fields(5).Value
Text1(6).Text = aRS.Fields(6).Value
Text1(7).Text = aRS.Fields(7).Value
'''''''''''''''''''''
''acquire data for secondary table'''''''''
bSQL = "select * from AGESEC WHERE PRIMKEY=" + Trim(Str(K0))
Set bRS = dbCurrent.OpenRecordset(bSQL)
L0 = bRS.Fields(0).Value
L1 = bRS.Fields(1).Value
Text2(0).Text = bRS.Fields(0).Value
Text2(1).Text = bRS.Fields(1).Value
Text2(2).Text = bRS.Fields(2).Value
Text2(3).Text = bRS.Fields(3).Value
''acquire data for tertiary table'''''''''
cSQL = "select * from AGETER WHERE PRIMKEY=" + Trim(Str(L0)) + "And
SECAUTO=" + Trim(Str(L1))
Set cRS = dbCurrent.OpenRecordset(cSQL)
Text3(0).Text = cRS.Fields(0).Value
Text3(1).Text = cRS.Fields(1).Value
Text3(2).Text = cRS.Fields(2).Value
End Sub
-- Maurice I. Muoneke