Updating the CustomerCountry combo box, will filter the results in the TrainerName combo box and similarly when the user updates the TrainerName combo box, the results in the SportsCentre combo box are filtered.
The Data Row Source code for the CustomerCountry combo box:-
Expand|Select|Wrap|Line Numbers
- SELECT tblCountry.[Country Code], tblCountry.Country FROM tblCountry;
Expand|Select|Wrap|Line Numbers
- SELECT tblTrainers.TrainerName FROM tblTrainers WHERE (((tblTrainers.TrainerCountry)=[Forms]![frmOrders].[Controls]![CustomerCountry].[Value]));
Expand|Select|Wrap|Line Numbers
- SELECT tblSportsCentre.SportsCentreName FROM tblSportsCentre INNER JOIN tblTrainers ON tblSportsCentre.SportsCentreName = tblTrainers.SportsCentreName WHERE (((tblTrainers.TrainerName)=[Forms]![frmOrders].[Controls]![TrainerName].[Value]));
You cannot add or change a record because a related record is required in table 'tblTrainers'.
The line 17 of following VBA code is highlighted in yellow:
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Option Explicit
- ' function that checks form is closed or open.
- Function fIsLoaded(ByVal strFormName As String) As Boolean
- fIsLoaded = False
- If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
- If Forms(strFormName).CurrentView <> 0 Then
- fIsLoaded = True
- End If
- End If
- End Function
- ' refresh our form (CheckBox for Trainers)
- Private Sub Form_Close()
- If fIsLoaded("frmOrders") Then
- Forms![frmOrders].Refresh
- End If
- End Sub
Is there a problem with the VBA code?