C
crystal.gatewood
I have just been given this database to maintain/manage updates... in
the process of adding me to it as an admin, it was discovered that the
Add New User form's submit button is not adding new users to the
database. It is a splti database in Office 2007.
Here is the code as I found it:
'==============================================================================
Private Sub Save_Button_Click()
'==============================================================================
On Error GoTo Err_Save_Button_Click
Dim TempLeadEmailAddress As String
Dim TempManagerEmailAddress As String
Dim SQL As String
Dim dbs As Database
Dim rst1 As Recordset
Dim SQL1 As String
Set dbs = CurrentDb
'--------------------------------------------------------------------------------------------
' Check to make sure all required fields are entered, if not a message
prompts the user
' to enter the missing field followed by exiting the procedure
'--------------------------------------------------------------------------------------------
'User's name textbox
If (IsNull(Me![UserName_TextBox])) Then
MsgBox ("I am sorry The Users Name has been left blank, please
enter the name.")
Exit Sub
End If
'User's Email address
If (IsNull(Me![UserEmail_Textbox])) Then
MsgBox ("I am sorry The Users Email Address has been left
blank, please enter the " & _
"Email Address.")
Exit Sub
End If
'User's manager
If (IsNull(Me![MgrName_Textbox])) Then
MsgBox ("I am sorry The Users Manager has been left blank,
please enter the Manager.")
Exit Sub
End If
'User's home site
If (IsNull(Me![Site])) Then
MsgBox ("I am sorry The Users Site has been left blank, please
enter the Site.")
Exit Sub
End If
'User's Level
'Level 1=Administrator, 2 = Manager, 3 = Lead, 4 = SQE
If (IsNull(Me![Level])) Then
MsgBox ("I am sorry The Users Level has been left blank, please
enter the Level.")
Exit Sub
End If
'Check to make sure that if the level is 4 (Regular SQE) then
the must have a Lead
If (Level.Value = 4) Then
If (IsNull(Me![LeadName_Textbox])) Then
MsgBox ("I am sorry The Users Lead has been left blank,
please enter the " & _
"Lead Name.")
Exit Sub
End If
End If
'Check to see if user all ready exists
SQL1 = "SELECT SQE_Table.SQE_Text " & _
"FROM SQE_Table " & _
"WHERE (((SQE_Table.SQE_Text)=" & _
" '" + UserName_TextBox.Value + "' ));"
Set rst1 = dbs.OpenRecordset(SQL1)
If (rst1.RecordCount = 1) Then
Call RecordActions("Create", "Profile", UserName_TextBox.Value,
"Fail", errAlreadyExisted)
MsgBox ("I am sorry that user all ready exists....")
Exit Sub
End If
rst1.Close
SQL1 = "SELECT SQE_Table.SQEEmail_Text " & _
"FROM SQE_Table " & _
"WHERE (((SQE_Table.SQE_Text) =" & _
" '" + LeadName_Textbox.Value + "' ));"
Set rst1 = dbs.OpenRecordset(SQL1)
TempLeadEmailAddress = rst1![SQEEmail_Text]
rst1.Close
SQL1 = "SELECT SQE_Table.SQEEmail_Text " & _
"FROM SQE_Table " & _
"WHERE (((SQE_Table.SQE_Text) =" & _
" '" + MgrName_Textbox.Value + "' ));"
Set rst1 = dbs.OpenRecordset(SQL1)
TempManagerEmailAddress = rst1![SQEEmail_Text]
rst1.Close
dbs.Close
SQL = "INSERT INTO SQE_Table(SQE_Text, SQEEmail_Text, Lead_Text, "
& _
"LeadEmail_Text, MGREmail_Text, Password_Text, Level_Text,
Site_Text) " & _
"Select" & _
"'" + UserName_TextBox.Value + "', " & _
"'" + Me.UserEmail_Textbox.Value + "', " & _
"'" + Me.LeadName_Textbox.Value + "', " & _
"'" + TempLeadEmailAddress + "', " & _
"'" + TempManagerEmailAddress + "', " & _
"'aero', " & _
"'" + Me.Level.Value + "', " & _
"'" + Me.Site.Value + "' ;"
DoCmd.RunSQL SQL
'create action log
Call RecordActions("Create", "Profile", UserName_TextBox.Value,
"Success")
MsgBox ("User has been added, the password has been set to aero.")
Exit_Save_Button_Click:
Exit Sub
Err_Save_Button_Click:
MsgBox Err.Description
Resume Exit_Save_Button_Click
End Sub
'==============================================================================
(Yes, the message box shows whether it was successful or not, though
they swear this thing worked before.) I initially changed the INSERT
INTO statement to:
SQL = "INSERT INTO SQE_Table(SQE_Text, SQEEmail_Text, Lead_Text, " & _
"LeadEmail_Text, MGREmail_Text, Password_Text, Level_Text,
Site_Text) " & _
"VALUES(" & _
"'" + UserName_TextBox.Value + "', " & _
"'" + Me.UserEmail_Textbox.Value + "', " & _
"'" + Me.LeadName_Textbox.Value + "', " & _
"'" + TempLeadEmailAddress + "', " & _
"'" + TempManagerEmailAddress + "', " & _
"'aero', " & _
"'" + Me.Level.Value + "', " & _
"'" + Me.Site.Value + "') ;"
DoCmd.RunSQL SQL
to no avail - the only difference this makes is that Access doesn't
even recognize that the save button was clicked. I have taken the code
out of the button... no matter if I try to add the new user by using
DoCmd.RunSQL or if I try rst1.AddNew & rst1.Update, I cannot figure
out why the new record is not added.
the process of adding me to it as an admin, it was discovered that the
Add New User form's submit button is not adding new users to the
database. It is a splti database in Office 2007.
Here is the code as I found it:
'==============================================================================
Private Sub Save_Button_Click()
'==============================================================================
On Error GoTo Err_Save_Button_Click
Dim TempLeadEmailAddress As String
Dim TempManagerEmailAddress As String
Dim SQL As String
Dim dbs As Database
Dim rst1 As Recordset
Dim SQL1 As String
Set dbs = CurrentDb
'--------------------------------------------------------------------------------------------
' Check to make sure all required fields are entered, if not a message
prompts the user
' to enter the missing field followed by exiting the procedure
'--------------------------------------------------------------------------------------------
'User's name textbox
If (IsNull(Me![UserName_TextBox])) Then
MsgBox ("I am sorry The Users Name has been left blank, please
enter the name.")
Exit Sub
End If
'User's Email address
If (IsNull(Me![UserEmail_Textbox])) Then
MsgBox ("I am sorry The Users Email Address has been left
blank, please enter the " & _
"Email Address.")
Exit Sub
End If
'User's manager
If (IsNull(Me![MgrName_Textbox])) Then
MsgBox ("I am sorry The Users Manager has been left blank,
please enter the Manager.")
Exit Sub
End If
'User's home site
If (IsNull(Me![Site])) Then
MsgBox ("I am sorry The Users Site has been left blank, please
enter the Site.")
Exit Sub
End If
'User's Level
'Level 1=Administrator, 2 = Manager, 3 = Lead, 4 = SQE
If (IsNull(Me![Level])) Then
MsgBox ("I am sorry The Users Level has been left blank, please
enter the Level.")
Exit Sub
End If
'Check to make sure that if the level is 4 (Regular SQE) then
the must have a Lead
If (Level.Value = 4) Then
If (IsNull(Me![LeadName_Textbox])) Then
MsgBox ("I am sorry The Users Lead has been left blank,
please enter the " & _
"Lead Name.")
Exit Sub
End If
End If
'Check to see if user all ready exists
SQL1 = "SELECT SQE_Table.SQE_Text " & _
"FROM SQE_Table " & _
"WHERE (((SQE_Table.SQE_Text)=" & _
" '" + UserName_TextBox.Value + "' ));"
Set rst1 = dbs.OpenRecordset(SQL1)
If (rst1.RecordCount = 1) Then
Call RecordActions("Create", "Profile", UserName_TextBox.Value,
"Fail", errAlreadyExisted)
MsgBox ("I am sorry that user all ready exists....")
Exit Sub
End If
rst1.Close
SQL1 = "SELECT SQE_Table.SQEEmail_Text " & _
"FROM SQE_Table " & _
"WHERE (((SQE_Table.SQE_Text) =" & _
" '" + LeadName_Textbox.Value + "' ));"
Set rst1 = dbs.OpenRecordset(SQL1)
TempLeadEmailAddress = rst1![SQEEmail_Text]
rst1.Close
SQL1 = "SELECT SQE_Table.SQEEmail_Text " & _
"FROM SQE_Table " & _
"WHERE (((SQE_Table.SQE_Text) =" & _
" '" + MgrName_Textbox.Value + "' ));"
Set rst1 = dbs.OpenRecordset(SQL1)
TempManagerEmailAddress = rst1![SQEEmail_Text]
rst1.Close
dbs.Close
SQL = "INSERT INTO SQE_Table(SQE_Text, SQEEmail_Text, Lead_Text, "
& _
"LeadEmail_Text, MGREmail_Text, Password_Text, Level_Text,
Site_Text) " & _
"Select" & _
"'" + UserName_TextBox.Value + "', " & _
"'" + Me.UserEmail_Textbox.Value + "', " & _
"'" + Me.LeadName_Textbox.Value + "', " & _
"'" + TempLeadEmailAddress + "', " & _
"'" + TempManagerEmailAddress + "', " & _
"'aero', " & _
"'" + Me.Level.Value + "', " & _
"'" + Me.Site.Value + "' ;"
DoCmd.RunSQL SQL
'create action log
Call RecordActions("Create", "Profile", UserName_TextBox.Value,
"Success")
MsgBox ("User has been added, the password has been set to aero.")
Exit_Save_Button_Click:
Exit Sub
Err_Save_Button_Click:
MsgBox Err.Description
Resume Exit_Save_Button_Click
End Sub
'==============================================================================
(Yes, the message box shows whether it was successful or not, though
they swear this thing worked before.) I initially changed the INSERT
INTO statement to:
SQL = "INSERT INTO SQE_Table(SQE_Text, SQEEmail_Text, Lead_Text, " & _
"LeadEmail_Text, MGREmail_Text, Password_Text, Level_Text,
Site_Text) " & _
"VALUES(" & _
"'" + UserName_TextBox.Value + "', " & _
"'" + Me.UserEmail_Textbox.Value + "', " & _
"'" + Me.LeadName_Textbox.Value + "', " & _
"'" + TempLeadEmailAddress + "', " & _
"'" + TempManagerEmailAddress + "', " & _
"'aero', " & _
"'" + Me.Level.Value + "', " & _
"'" + Me.Site.Value + "') ;"
DoCmd.RunSQL SQL
to no avail - the only difference this makes is that Access doesn't
even recognize that the save button was clicked. I have taken the code
out of the button... no matter if I try to add the new user by using
DoCmd.RunSQL or if I try rst1.AddNew & rst1.Update, I cannot figure
out why the new record is not added.