F
Fab-Ulus
This code kept returning the error - "COMPILE ERROR - User-defined type not
defined" while highlighting "dbs AS Database". If anyone can help, it would
be much appreciated
Private Sub btnAddRecords_Click()
On Error GoTo Err_btnAddRecords_Click
Dim dbs As Database
Dim rst As Recordset
Dim rst2 As Recordset
Dim LoopIndex As Integer
Dim LoopIndex2 As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM TrainRoleJunc WHERE [Trainer ID]
= " & [Trainer ID].Value, dbOpenDynaset, dbSeeChanges)
Set rst2 = dbs.OpenRecordset("SELECT * FROM TRS WHERE [Trainerrole ID] = " &
[Trainerrolejunc]![TrainerRole ID], dbOpenDynaset, dbSeeChanges)
For LoopIndex = 1 To 6
rst.addnew
rst![Trainer ID] = [Trainer ID].Value
rst![Role ID] = LoopIndex
rst.Update
For LoopIndex2 = 1 To 11
rst2.addnew
rst2![TrainerRole ID] = rst![TrainerRole ID]
rst2![Subject ID] = LoopIndex2
Next LoopIndex2
Next LoopIndex
Exit_btnAddRecords_Click:
Exit Sub
Err_btnAddRecords_Click:
MsgBox Err.Description
Resume Exit_btnAddRecords_Click
End Sub
defined" while highlighting "dbs AS Database". If anyone can help, it would
be much appreciated
Private Sub btnAddRecords_Click()
On Error GoTo Err_btnAddRecords_Click
Dim dbs As Database
Dim rst As Recordset
Dim rst2 As Recordset
Dim LoopIndex As Integer
Dim LoopIndex2 As Integer
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT * FROM TrainRoleJunc WHERE [Trainer ID]
= " & [Trainer ID].Value, dbOpenDynaset, dbSeeChanges)
Set rst2 = dbs.OpenRecordset("SELECT * FROM TRS WHERE [Trainerrole ID] = " &
[Trainerrolejunc]![TrainerRole ID], dbOpenDynaset, dbSeeChanges)
For LoopIndex = 1 To 6
rst.addnew
rst![Trainer ID] = [Trainer ID].Value
rst![Role ID] = LoopIndex
rst.Update
For LoopIndex2 = 1 To 11
rst2.addnew
rst2![TrainerRole ID] = rst![TrainerRole ID]
rst2![Subject ID] = LoopIndex2
Next LoopIndex2
Next LoopIndex
Exit_btnAddRecords_Click:
Exit Sub
Err_btnAddRecords_Click:
MsgBox Err.Description
Resume Exit_btnAddRecords_Click
End Sub