[INCLUDE]
MySQL_EscapeField
MySQL_EscapeValue
MySQL_Query_InsertUpdate

[DEFINE]
Private MySQL_MultiInsert_AUsed As Boolean
Private MySQL_MultiInsert_First As Boolean
Private MySQL_MultiInsert_FCace As String
Private MySQL_MultiInsert_VCace As String
Private MySQL_MultiInsert_RCace As String

[CODE]
Public Function MySQL_MultiInsert_Create() As Long
  If MySQL_MultiInsert_AUsed Then
    Call MsgBox("MultiInsert Detected", vbCritical Or vbOKOnly)
    End
    End If
  MySQL_MultiInsert_AUsed = True
  MySQL_MultiInsert_Create = 1&
  MySQL_MultiInsert_First = True
  End Function

Public Sub MySQL_MultiInsert_AddField(ByVal MMIData As Long, ByVal xField As String, xValue As Variant)
  If MySQL_MultiInsert_First Then
    MySQL_MultiInsert_FCace = MySQL_MultiInsert_FCace + ", " + MySQL_EscapeField(xField)
    End If
  MySQL_MultiInsert_VCace = MySQL_MultiInsert_VCace + ", " + MySQL_EscapeVarValue(xValue)
  End Sub

Public Sub MySQL_MultiInsert_NextRow(ByVal MMIData As Long)
  MySQL_MultiInsert_RCace = MySQL_MultiInsert_RCace + "), (" + Mid(MySQL_MultiInsert_VCace, 3&)
  MySQL_MultiInsert_VCace = ""
  MySQL_MultiInsert_First = False
  End Sub

Public Function MySQL_MultiInsert_Insert(ByVal MMIData As Long, ByVal xTable As String) As Boolean
  If Len(MySQL_MultiInsert_VCace) = 0& Then
    If (Len(MySQL_MultiInsert_FCace) = 0& Or Len(MySQL_MultiInsert_RCace) = 0&) Then
      If (Len(MySQL_MultiInsert_FCace) = 0& And Len(MySQL_MultiInsert_RCace) = 0&) Then
        MySQL_MultiInsert_Insert = True
        End If
      Else
      MySQL_MultiInsert_Insert = MySQL_Query_InsertUpdate("INSERT INTO " + MySQL_EscapeField(xTable) + "(" + Mid(MySQL_MultiInsert_FCace, 3&) + ") VALUES " + Mid(MySQL_MultiInsert_RCace, 4&) + ");")
      End If
    End If
  End Function

Public Sub MySQL_MultiInsert_Discard(ByVal MMIData As Long)
  MySQL_MultiInsert_FCace = ""
  MySQL_MultiInsert_VCace = ""
  MySQL_MultiInsert_RCace = ""
  MySQL_MultiInsert_AUsed = False
  MySQL_MultiInsert_First = True
  End Sub
