Still having problems... I might not be grasping the full NZ function thing... I am going to post the code in its original form... then the butchered attempts I've been making.
Code:
Sub LnMpwReset()
Dim oLnM As InternetExplorer
Dim User, Pass As String
Dim strUser, strPass As String
On Error Resume Next
User = DLookup("[chrWebuser]", "tblWebCreds", "chrWebTools='Labs Meds Admin'")
Pass = DLookup("[chrWebpass]", "tblWebCreds", "chrWebTools='Labs Meds Admin'")
If Err.Number = 94 Then
MsgBox "Username or Password is missing", vbCritical, "LIFT MESSAGE"
DoCmd.OpenForm "frmWebCreds"
Exit Sub
End If
Set oLnM = Login("Login site", True)
If InStr(oLnM.Document.Body.innertext, "You have multiple sessions open") > 0 Then
oLnM.Document.all.Item("SubmitContinueSession").Click
Call SleepIE(oLnM)
End If
oLnM.Document.all.Item("j_username").Value = User
oLnM.Document.all.Item("j_password").Value = Pass
oLnM.Document.all.Item("login").Click
''''''''''''''''wrong password
Call SleepIE(oLnM)
If InStr(oLnM.Document.Body.innertext, "Login Failed") > 0 Then
oLnM.Navigate "javascript:alert('Please Check your credentials.');"
Exit Sub
End If
'''''''''''''''multiple sessions
If InStr(oLnM.Document.Body.innertext, "You have multiple sessions open. Continuing will end your previous session") > 0 Then
oLnM.Document.all.Item("SubmitContinueSession").Click
Call SleepIE(oLnM)
End If
Call SleepIE(oLnM)
oLnM.Navigate "Website we are going to"
Call SleepIE(oLnM)
PauseApp 0.4
oLnM.Document.all.Item("clearButton").Click
Call SleepIE(oLnM)
If Forms("frmmainnew").txtLNMuid <> "" Then
oLnM.Document.all.Item("firstResponder").Value = Forms("frmmainnew").txtLNMuid.Value
End If
If Forms("frmmainnew").txtlnmLast <> "" Then
oLnM.Document.all.Item("$TextField$1").Value = Forms("frmmainnew").txtlnmLast.Value
End If
If Forms("frmmainnew").txtlnmFirst <> "" Then
oLnM.Document.all.Item("$TextField$2").Value = Forms("frmmainnew").txtlnmFirst.Value
End If
PauseApp 0.4
oLnM.Document.all.Item("searchButton").Click
End Sub
The code above, if ("frmmainnew").txtLNMuid was blank on the form, it was sending "null" to the browser.. I have tried a handful of things... My last attempt at understanding null and NZ made me think I needed to dim those textboxes as variant so I could use the nz variant..
Code:
Sub LnMpwReset()
Dim oLnM As InternetExplorer
Dim User, Pass As String
Dim strUser, strPass As String
Dim UiD, LastN, FirstN As Variant
On Error GoTo Err:
UiD = Forms("frmmainnew").txtLNMuid.Value
LastN = Forms("frmmainnew").txtlnmLast.Value
FirstN = Forms("frmmainnew").txtlnmFirst.Value
Errecs:
On Error Resume Next
User = DLookup("[chrWebuser]", "tblWebCreds", "chrWebTools='Labs Meds Admin'")
Pass = DLookup("[chrWebpass]", "tblWebCreds", "chrWebTools='Labs Meds Admin'")
If Err.Number = 94 Then
MsgBox "Username or Password is missing", vbCritical, "LIFT MESSAGE"
DoCmd.OpenForm "frmWebCreds"
Exit Sub
End If
Set oLnM = Login("Login site", True)
If InStr(oLnM.Document.Body.innertext, "You have multiple sessions open") > 0 Then
oLnM.Document.all.Item("SubmitContinueSession").Click
Call SleepIE(oLnM)
End If
oLnM.Document.all.Item("j_username").Value = User
oLnM.Document.all.Item("j_password").Value = Pass
oLnM.Document.all.Item("login").Click
''''''''''''''''wrong password
Call SleepIE(oLnM)
If InStr(oLnM.Document.Body.innertext, "Login Failed") > 0 Then
oLnM.Navigate "javascript:alert('Please Check your credentials.');"
Exit Sub
End If
'''''''''''''''multiple sessions
If InStr(oLnM.Document.Body.innertext, "You have multiple sessions open. Continuing will end your previous session") > 0 Then
oLnM.Document.all.Item("SubmitContinueSession").Click
Call SleepIE(oLnM)
End If
Call SleepIE(oLnM)
oLnM.Navigate "Website we are going to"
Call SleepIE(oLnM)
PauseApp 0.4
oLnM.Document.all.Item("clearButton").Click
Call SleepIE(oLnM)
If UiD = "" Then
GoTo skipUid:
End If
oLnM.Document.all.Item("firstResponder").Value = UiD
skipUid:
If Forms("frmmainnew").txtlnmLast Is Null Then
GoTo skipLast:
End If
oLnM.Document.all.Item("$TextField$1").Value = LastN
skipLast:
If Forms("frmmainnew").txtlnmFirst <> "" Then
GoTo skipfirst:
End If
oLnM.Document.all.Item("$TextField$2").Value = FirstN
skipfirst:
PauseApp 0.4
oLnM.Document.all.Item("searchButton").Click
Err:
If UiD = Nz(UiD, "") Then
End If
If LastN = Nz(LastN, "") Then
End If
If FirstN = Nz(FirstN, "") Then
End If
GoTo Errecs:
End Sub
The code above here is my attempting a lot of different methods. While searching null and NZ, I find alot of things ment for inside queries but not a whole lot in actual VBA code.