E
esn
I'm struggling my way through putting some code together but I don't
know VBA very well. I'm working with a form where a user enters the
name of a table and selects a few options to modify the data in that
table. Each option should call a vba function I've saved in a
module. If I call the functions from a separate macro they all work
just right, but when I put this code in the onclick event for the
button, nothing happens. I've tried hitting the button with nothing
entered in the table name field, and I don't even get the message box
instructing the user to enter a table name. I'm sure I've done
something stupid in here somewhere...
Code:
Private Sub ResultsGo_Click()
On Error GoTo Error_Handler
If Me!TableName Is Null Then
MsgBox "Enter a table name."
Else
Dim strTable As String
strTable = CHR34 & Me!TableName & CHR34
Dim ResultsTbl As AccessObject
Set ResultsTbl = Application.CurrentData.AllTables(strTable)
If ResultsTbl.IsLoaded = True Then
MsgBox "Close the table and try again."
Else
If Me![OptionTransform] = -1 Then
TransformVars (strTable)
End If
If Me![OptionModify] = -1 Then
OutlierMod (strTable)
End If
If Me![OptionStandardize] = -1 Then
Standardize (strTable)
End If
End If
End If
DoCmd.Close acForm, "Prepare Results for SAS"
DoCmd.OpenTable strTable
GoButtonExit:
Set db = Nothing
Exit Sub
Error_Handler:
Select Case Err
Case 3265& 'Table name invalid
MsgBox strTableName & " table doesn't exist"
Case Else
Debug.Print "TableInfo() Error " & Err & ": " & Error
End Select
Resume GoButtonExit
End Sub
know VBA very well. I'm working with a form where a user enters the
name of a table and selects a few options to modify the data in that
table. Each option should call a vba function I've saved in a
module. If I call the functions from a separate macro they all work
just right, but when I put this code in the onclick event for the
button, nothing happens. I've tried hitting the button with nothing
entered in the table name field, and I don't even get the message box
instructing the user to enter a table name. I'm sure I've done
something stupid in here somewhere...
Code:
Private Sub ResultsGo_Click()
On Error GoTo Error_Handler
If Me!TableName Is Null Then
MsgBox "Enter a table name."
Else
Dim strTable As String
strTable = CHR34 & Me!TableName & CHR34
Dim ResultsTbl As AccessObject
Set ResultsTbl = Application.CurrentData.AllTables(strTable)
If ResultsTbl.IsLoaded = True Then
MsgBox "Close the table and try again."
Else
If Me![OptionTransform] = -1 Then
TransformVars (strTable)
End If
If Me![OptionModify] = -1 Then
OutlierMod (strTable)
End If
If Me![OptionStandardize] = -1 Then
Standardize (strTable)
End If
End If
End If
DoCmd.Close acForm, "Prepare Results for SAS"
DoCmd.OpenTable strTable
GoButtonExit:
Set db = Nothing
Exit Sub
Error_Handler:
Select Case Err
Case 3265& 'Table name invalid
MsgBox strTableName & " table doesn't exist"
Case Else
Debug.Print "TableInfo() Error " & Err & ": " & Error
End Select
Resume GoButtonExit
End Sub