ORIGINAL SOURCE CODE FOR SQL.FRM

Made on Tuesday, Apr 8, 2003 at 9:43 AM

http://www.resourcemining.com

SQL.FRM contained 13 resource strings and 16 non-user interface strings.

Option Explicit
'>>>>>>>>>>>>>>>>>>>>>>>>
'ResMe Converted To A Property: Const FORMCAPTION = "SQL Statement"
'ResMe Converted To A Property: Const BUTTON1 = "&Execute"
'ResMe Converted To A Property: Const BUTTON2 = "&Clear"
'ResMe Converted To A Property: Const BUTTON3 = "&Save"
'ResMe Converted To A Property: Const MSG1 = "Update"
'ResMe Converted To A Property: Const MSG2 = "Enter QueryDef Name:"
'ResMe Converted To A Property: Const MSG3 = "Is this a SQLPassThrough QueryDef?"
'ResMe Converted To A Property: Const MSG4 = "Enter Connect property value:"
'ResMe Converted To A Property: Const MSG5 = "Is the Query Row Returning?"
'>>>>>>>>>>>>>>>>>>>>>>>>


Private Sub cmdClearSQL_Click()
  txtSQLStatement.Text = vbNullString
  txtSQLStatement.SetFocus
End Sub

Private Sub cmdSaveQueryDef_Click()
  On Error GoTo SQDErr

  Dim sQueryName As String
  Dim sTmp As String
  Dim qdNew As QueryDef

  If Not gnodDBNode Is Nothing Then
    If gnodDBNode.Tag = QUERY_STR Then
      'a querydef is selected so user may want to update it's SQL
      If MsgBox(MSG1 & " '" & gnodDBNode.Text & "'?", vbYesNo + vbQuestion) = vbYes Then
        'store the SQL from the SQL Window in the currently
        'selected querydef
        gdbCurrentDB.QueryDefs(gnodDBNode.Text).SQL = Me.txtSQLStatement.Text
        Exit Sub
      End If
    End If
  End If
  
  'either there is no current querydef selected or the user
  'didn't want to update the current one so we need
  'to propmpt for a new name
  sQueryName = InputBox(MSG2)
  If Len(sQueryName) = 0 Then Exit Sub
  
  'check for a dupe and exit if the user won't overwrite it
  If DupeTableName(sQueryName) Then
    Exit Sub
  End If
    
  'add the new querydef
  Set qdNew = gdbCurrentDB.CreateQueryDef(sQueryName)
  'prompt for passthrough querydef
  If MsgBox(MSG3, vbYesNo + vbQuestion + vbDefaultButton2) = vbYes Then
    sTmp = InputBox(MSG4)
    If Len(sTmp) > 0 Then
      qdNew.Connect = sTmp
      If MsgBox(MSG5, vbYesNo + vbQuestion) = vbNo Then
        qdNew.ReturnsRecords = False
      End If
    End If
  End If
  qdNew.SQL = txtSQLStatement.Text
  
  gdbCurrentDB.QueryDefs.Refresh
  RefreshTables Nothing

  Exit Sub

SQDErr:
  ShowError
End Sub

Private Sub Form_Unload(Cancel As Integer)
  'only save the sql text if there are no carriage returns in it
  'because they are not preserved in the Registry
'  If InStr(frmSQL.txtSQLStatement.Text, Chr(13)) = 0 Then
    SaveSetting APP_CATEGORY, APPNAME, "SQLStatement", frmSQL.txtSQLStatement.Text
'  End If
  If frmSQL.WindowState = vbNormal Then
    SaveSetting APP_CATEGORY, APPNAME, "SQLWindowTop", frmSQL.Top
    SaveSetting APP_CATEGORY, APPNAME, "SQLWindowLeft", frmSQL.Left
    SaveSetting APP_CATEGORY, APPNAME, "SQLWindowWidth", frmSQL.Width
    SaveSetting APP_CATEGORY, APPNAME, "SQLWindowHeight", frmSQL.Height
  End If
End Sub

Private Sub txtSQLStatement_Change()
  cmdExecuteSQL.Enabled = Len(txtSQLStatement.Text) > 0
End Sub

Private Sub cmdExecuteSQL_Click()
  If Len(txtSQLStatement.Text) = 0 Then Exit Sub

  OpenQuery txtSQLStatement.Text, True
End Sub

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  If KeyCode = vbKeyF1 And Shift = 0 Then
    DisplayTopic 2016144
  End If
End Sub

Private Sub Form_Load()
    'ResMe autogenerated line of code to call the initialization routine that was automatically generated.
    Call frmSQL_Auto_Init
  Me.Caption = FORMCAPTION
  cmdExecuteSQL.Caption = BUTTON1
  cmdClearSQL.Caption = BUTTON2
  cmdSaveQueryDef.Caption = BUTTON3
  
  txtSQLStatement.Text = GetRegistryString("SQLStatement", vbNullString)
 
  Me.Height = Val(GetRegistryString("SQLWindowHeight", "3000"))
  Me.Width = Val(GetRegistryString("SQLWindowWidth", "5370"))
  Me.Top = Val(GetRegistryString("SQLWindowTop", "0"))
  Me.Left = Val(GetRegistryString("SQLWindowLeft", "3850"))

End Sub

Private Sub Form_Resize()
  On Error Resume Next

  If WindowState <> vbMinimized Then
    txtSQLStatement.Width = Me.ScaleWidth - (txtSQLStatement.Left * 2)
    txtSQLStatement.Height = Me.ScaleHeight - (txtSQLStatement.Top + 50)
  End If
End Sub

Private Sub txtSQLStatement_DragDrop(Source As Control, x As Single, y As Single)
  If Source = frmDatabase.tvDatabase Then
    frmSQL.txtSQLStatement.Text = gdbCurrentDB.QueryDefs(gnodDBNode.Text).SQL
  End If
End Sub


'*********************************************************************************
'**          This Section Of Code Was Automatically Generated By ResMe          **
'**                                                                             **
'** String assignments to Constants have been converted to read-only properties **
'*********************************************************************************


'This was: Const FORMCAPTION = "SQL Statement"
Property Get FORMCAPTION As String
    FORMCAPTION = "SQL Statement"
End Property

'This was: Const BUTTON1 = "&Execute"
Property Get BUTTON1 As String
    BUTTON1 = "&Execute"
End Property

'This was: Const BUTTON2 = "&Clear"
Property Get BUTTON2 As String
    BUTTON2 = "&Clear"
End Property

'This was: Const BUTTON3 = "&Save"
Property Get BUTTON3 As String
    BUTTON3 = "&Save"
End Property

'This was: Const MSG1 = "Update"
Property Get MSG1 As String
    MSG1 = "Update"
End Property

'This was: Const MSG2 = "Enter QueryDef Name:"
Property Get MSG2 As String
    MSG2 = "Enter QueryDef Name:"
End Property

'This was: Const MSG3 = "Is this a SQLPassThrough QueryDef?"
Property Get MSG3 As String
    MSG3 = "Is this a SQLPassThrough QueryDef?"
End Property

'This was: Const MSG4 = "Enter Connect property value:"
Property Get MSG4 As String
    MSG4 = "Enter Connect property value:"
End Property

'This was: Const MSG5 = "Is the Query Row Returning?"
Property Get MSG5 As String
    MSG5 = "Is the Query Row Returning?"
End Property


Private Sub frmSQL_Auto_Init()
'This routine initializes all User Interface control properties on frmSQL.
'This section of code was automatically generated by the ResMe String Extraction Utility.
    Me.Caption = "SQL"
    cmdSaveQueryDef.Caption = "&Save"
    cmdExecuteSQL.Caption = "&Execute"
    cmdClearSQL.Caption = "&Clear"
End Sub