question

JohnRichter-2981 avatar image
0 Votes"
JohnRichter-2981 asked

I need to save the result ( DISTINCT OPRID) of the query below to a variable so when I can change the current value of the variable oprid to the new value returned from the query. What is the simplist way to do so?

MsgBox "USER DNS DOMAIN = " & Environ("USERDNSDOMAIN") & " " & "USERNAME = " & LCase(Environ("USERNAME"))
Usrname = LCase(Environ("USERNAME"))
USERDNSNAME = Environ("USERDNSDOMAIN")
Usrname = "jbritt"
USERDNSNAME = "ENT.COVANCE.COM"


'If the USERDNSNAME (Domain) is equal to "ENT.COVANCE.COM" switch OPRID to a Labcorp PeopleSoft OPRID from the XREF table

If USERDNSNAME = "ENT.COVANCE.COM" Then
Set PSData = CreateObject("ADODB.Recordset")

 RUNSQL = "SELECT DISTINCT O.OPRID FROM SYSADM.PS_LCA_MACRO_XREF O WHERE O.USERID =  '" & Usrname & "'"
 RowCount = 0
 With PSData
     .Open Source:=RUNSQL, ActiveConnection:=PSConnection, CursorType:=3  'adOpenStatic
     RowCount = PSData.RecordCount
     Oprid = Oprid
     .Close
 End With
 Set PSData = Nothing
 If RowCount <> 1 Then
     PSConnection.Close
     Set PSConnection = Nothing
     msg = "Error: You do not have a login ID that is set up in Diagnostics PeopleSoft"
     response = MsgBox(msg, 16, title)
     Exit Sub
 End If

End If

office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers