GENERAL FUNCTION

The Q Function The QC Function The QCLF Function
The D Function The ShowError Function
    
    The Q Function
    
    Public Function Q(ByVal sField As String, Optional Char As String = "'") As String
        sField = Replace(sField, Char, Char + Char)
        sField = Char + sField + Char
        Q = sField
    End Function

    
    The Q function is used when consructing an SQL statement eg.
    
           sql = "Select * from tAddress where [Name] = " & q(strName)

    
           instead of
    
           sql = "Select * from tAddress where [Name] = '" & strName & "'"

    
          It is also use when inserting a text field containing and apostrophe, replacing
          the  with 2 apostrophes. E.G
    
          insert intro tAddress (Name,Phone) Values ('John's','555-2345')
    
          Will be changed to
    
          insert intro tAddress (Name,Phone) Values ('John''s','555-2345')
    
          when using the following syntax
    
          sql = ""
          sql = sql & "insert intro tAddress (Name,Phone) "
          sql = sql & "Values (
          sql = sql & q("John's") & "," & q("555-2345") & ")"


    
    
    The QC Function
    
    Public Function QC(ByVal sField As String, Optional Char As String = "'") As String
        sField = Replace(sField, Char, Char + Char)
        sField = Char + sField + Char
        QC = sField & ","
    End Function

    
    The QC (Quote Comma) function works the same as the Q function with the addition
    that it adds a comma at the end of the sting e.g.
    
          sql = ""
          sql = sql & "insert intro tAddress (Name,Phone) "
          sql = sql & "Values (
          sql = sql & qc("John's")
          sql = sql & q("555-2345") & ")"


    
    
    The QCLF Function
    
    Public Function QCLF(ByVal sField As String, Optional Char As String = "'") As String
        sField = Replace(sField, Char, Char + Char)
        sField = Char + sField + Char
        QCLF = sField & "," & vbCrLf
    End Function

    
    The QCLF (Quote Comma Line feed) function works the same as the Q function
    with the addition that it adds a comma and a vbCrLf at the end of the
    sting e.g.
    
          sql = ""
          sql = sql & "insert intro tAddress (Name,Phone) "
          sql = sql & "Values (
          sql = sql & qclf("John's")
          sql = sql & q("555-2345") & ")"
    
        Instead of
    
          sql = ""
          sql = sql & "insert intro tAddress (Name,Phone) "
          sql = sql & "Values (
          sql = sql & "'John''s'," & vbcrlf
          sql = sql & q("555-2345") & ")"


    
    
    The D Function
    
    Public Function D(Optional IncludeTime As Boolean = True) As String
        If IncludeTime = False Then
            D = "'" + Format(Date, "yyyy/mm/dd") + "'"
        Else
            D = "'" + Format(Date, "yyyy/mm/dd hh:mm:ss") + "'"
        End If
    End Function

    
    The D function is used to insert or update a date value in a table e.g.
    

        sql =""
        sql = sql & "Insert into tLog (Message,LofDate)"
        sql = sql & "values("
        sql = sql & qclf("Log Message 1")
        sql = sql & d() & ")" & vbcrlf


    
    
    The ShowError Function
    
    Public Sub ShowError(Optional CalledFrom As String = "")
            If CalledFrom Not = "" Then
              CalledFrom = CalledFrom & " - "
            End If
            MsgBox "Err:" & Err.Number & vbCrLf & Err.Description, _
                vbCritical, CalledFrom & "Error"
    End Sub

    
    The ShowError function is a public function to inform the user when
    an error has occured. e.g.
    

    public function Screensetup() as boolean
    on error goto errhandler:
      Screensetup = true
      ..
      ..
      ..
      exit function
    errhandler:
      screensetup = false
      ShowError "ScreenSetup"
    end function

    


          
1