
' -----------------------------------------------------------------
' Hands-On 6-1
' ----------------------------------------------------------------- 

Sub AskForPassword()
    Dim pWord As String
    
    pWord = ""
    Do While pWord <> "DADA"
        pWord = InputBox("What is the Report password?")
    Loop
    MsgBox "You entered the correct Report password."
End Sub


Sub AskForPassword2()
    Dim pWord As String
       
    pWord = ""
    Do While pWord <> "DADA"
        pWord = InputBox("What is the Report password?")
        If pWord = "" Then
            MsgBox "You did not enter a password."
            Exit Do
        End If
    Loop
    If pWord <> "" Then
        MsgBox "You entered the correct Report password."
    End If
End Sub


' -----------------------------------------------------------------
' Hands-On 6-2
' -----------------------------------------------------------------

Sub SignIn()
    Dim secretCode As String
    
    Do
        secretCode = InputBox("Enter your secret code:")
        If secretCode = "sp1045" Then Exit Do
    Loop While secretCode <> "sp1045"
End Sub

Sub SignIn2()
  Dim secretCode As String
    
  Do
     secretCode = InputBox("Enter your secret code:")
     If secretCode = "sp1045" Or secretCode = "" Then Exit Do
  Loop While secretCode <> "sp1045"
End Sub


' -----------------------------------------------------------------
' Hands-On 6-3
' -----------------------------------------------------------------

Sub AskForPassword3()
    Dim pWord As String
    
    pWord = ""
    Do Until pWord = "DADA"
        pWord = InputBox("What is the Report password?")
    Loop
End Sub

Sub AskForPassword4()
    Dim pWord As String
       
    pWord = ""
    Do Until pWord = "DADA"
        pWord = InputBox("What is the Report password?")
        If pWord = "" Then Exit Do
    Loop
End Sub


' -----------------------------------------------------------------
' Hands-On 6-4
' -----------------------------------------------------------------

Sub PrintNumbers()
    Dim num As Integer
    
    num = 0
    Do
        num = num + 1
        Debug.Print num
    Loop Until num = 27
End Sub


' -----------------------------------------------------------------
' Hands-On 6-5 -  Customers form
' -----------------------------------------------------------------

Sub GetTextBoxNames()
    Dim myForm As Form
    Dim myControl As Control
    Dim c As Integer
    
    Set myForm = Screen.ActiveForm
    Set myControl = Screen.ActiveControl
    
    For c = 0 To myForm.Count - 1
        If TypeOf myForm(c) Is TextBox Then
            MsgBox myForm(c).Name
        End If
    Next c
End Sub


' -----------------------------------------------------------------
' Hands-On 6-6
' -----------------------------------------------------------------


Sub GetControls()
    Dim myControl As Control
    Dim myForm As Form
    
    DoCmd.OpenForm "Customers"
    Set myForm = Screen.ActiveForm
    
    For Each myControl In myForm
        Debug.Print myControl.Name
    Next
End Sub


' -----------------------------------------------------------------
' Hands-On 6-7
' -----------------------------------------------------------------


Sub GetControls2()
    Dim myControl As Control
    Dim myForm As Form
    
    DoCmd.OpenForm "Customers"
    Set myForm = Screen.ActiveForm
    
    For Each myControl In myForm
        Debug.Print myControl.Name
        If myControl.Name = "Address" Then Exit For
    Next
End Sub


' -----------------------------------------------------------------
' Hands-On 6-8
' -----------------------------------------------------------------

Sub GetFormsAndControls()
    Dim accObj As AccessObject
    Dim myControl As Control
    
  
    For Each accObj In CurrentProject.AllForms
        Debug.Print accObj.Name & " Form"
         If Not accObj.IsLoaded Then
           DoCmd.OpenForm accObj.Name
         End If
         For Each myControl In Forms(accObj.Name).Controls
             Debug.Print Chr(9) & myControl.Name
         Next
         DoCmd.Close
     Next
End Sub
