Dim strSQL As String
DoCmd.Hourglass True
Application.Echo False, "Processing ..."
With Me
Select Case tabClients
Case 0 ' First TabPage (General)
' Do nothing. SourceObject loaded.
Case 1 ' Second TabPage (Academic)
'Load source objects on Academic tab
If .stuSchedule_subform.SourceObject <> "frm_STU_SCHEDULE" Then
.stuSchedule_subform.SourceObject = "frm_STU_SCHEDULE"
End If
If .academics_subform.SourceObject <> "frm_STU_ACAD" Then
.academics_subform.SourceObject = "frm_STU_ACAD"
End If
Case 2 ' Third TabPage (History)
'Find client history.
If DLookup("CLIENT_ID", "tbl_HISTORY", "CLIENT_ID = " & Me.CLIENT_ID) Then
.CLI_HISTORY_subform.SourceObject = "frm_CLI_HISTORY"
Else
'If no history is available, prompt user to add client history.
If MsgBox("No client history available. Would you like to add it now?", vbYesNo) = vbYes Then
'Insert a new record into in tbl_CLI_HISTORY
strSQL = "INSERT INTO tbl_HISTORY( CLIENT_ID ) VALUES (Me.CLIENT_ID)"
CurrentDb.Execute strSQL1, dbFailOnError
'Find new record and display as subform
If DLookup("CLIENT_ID", "tbl_HISTORY", "CLIENT_ID = " & Me.CLIENT_ID) Then
.CLI_HISTORY_subform.SourceObject = "frm_CLI_HISTORY"
End If
End If
End If
Case 3
' ...
Case 4
' ...
' ...
End Select
End With
DoCmd.Hourglass False
|