childrenfirst
Technical User
Hi,
I have tried to debug the code without success for a couple days. For some reason, the update string is not updating the User table, and ended up erroring out. The code checks if the WindowsUser (based on the value in txtFillWindowsUser) is on the User table first, and then check if the WindowsUser's email column is Null. If email column for this WindowsUser is null, update the email for this WindowsUser on the User table with the value in the text box, txtFillEmail.
Any help or advice will be greatly appreciated!
Private Sub cmdUpdateEmail_Click()
Dim strUpdateEmail As String
Dim strWindowsUser As String
Dim strEmail As String
Dim db As Database
strWindowsUser = Me.txtWindowsUser.Value
strEmail = Me.txtFillEmail.Value
If DCount("WindowsUser", "User", "WindowsUser= '" & Me.txtFillWindowsUser.Value & "'") <> 0 And IsNull(DLookup("Email", "User", "WindowsUser ='" & Me.txtFillWindowsUser.Value & "'")) Then
strUpdateEmail = "Update User SET Email = '" & strEmail & "' WHERE Windowsuser = '" & strWindowsUser & "'"
MsgBox strUpdateEmail
DoCmd.RunSQL strUpdateEmail
Else
End If
End Sub
I have tried to debug the code without success for a couple days. For some reason, the update string is not updating the User table, and ended up erroring out. The code checks if the WindowsUser (based on the value in txtFillWindowsUser) is on the User table first, and then check if the WindowsUser's email column is Null. If email column for this WindowsUser is null, update the email for this WindowsUser on the User table with the value in the text box, txtFillEmail.
Any help or advice will be greatly appreciated!
Private Sub cmdUpdateEmail_Click()
Dim strUpdateEmail As String
Dim strWindowsUser As String
Dim strEmail As String
Dim db As Database
strWindowsUser = Me.txtWindowsUser.Value
strEmail = Me.txtFillEmail.Value
If DCount("WindowsUser", "User", "WindowsUser= '" & Me.txtFillWindowsUser.Value & "'") <> 0 And IsNull(DLookup("Email", "User", "WindowsUser ='" & Me.txtFillWindowsUser.Value & "'")) Then
strUpdateEmail = "Update User SET Email = '" & strEmail & "' WHERE Windowsuser = '" & strWindowsUser & "'"
MsgBox strUpdateEmail
DoCmd.RunSQL strUpdateEmail
Else
End If
End Sub