' This funcion is used to open the browser
Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hWnd As Long, _
ByVal Operation As String, _
ByVal Filename As String, _
Optional ByVal Parameters As String, _
Optional ByVal Directory As String, _
Optional ByVal WindowStyle As Long = vbMinimizedFocus _
) As Long
'this function is used to get .ini data
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
Private Sub RMA_Changed()
Dim strUrl As String
Dim strRMA As String
Dim strType As String
strRMA = Me.RMANumber
strType = "1"
If strRMA = "" Then
Exit Sub
End If
'get the current directory
strUrl = CurDir
'read the ini file and get the SSRS report path
strUrl = GetReportPath("DD", "RMAReportPath", strUrl & "\DD.ini")
'add the report params to the URL
strUrl = strUrl & "&RETURNDOCID=" & strRMA & "&Return_Record_Type=" & strType
'open the browser
Dim lSuccess As Long
lSuccess = ShellExecute(0, "Open", strUrl)
End Sub
Function GetReportPath(ByVal strSectionName As String, ByVal strEntry As String, ByVal strIniPath As String) As String
'this funtion returns data from an ini file
Dim X As Long
Dim sSection As String, sEntry As String, sDefault As String
Dim sRetBuf As String, iLenBuf As Integer, sFileName As String
Dim sValue As String
On Error GoTo ErrGetSectionentry
sSection = strSectionName
sEntry = strEntry
sDefault = ""
sRetBuf = Strings.String$(256, 0) '256 null characters
iLenBuf = Len(sRetBuf$)
sFileName = strIniPath
X = GetPrivateProfileString(sSection, sEntry, "", sRetBuf, iLenBuf, sFileName)
sValue = Strings.Trim(Strings.Left$(sRetBuf, X))
If sValue <> "" Then
GetReportPath = sValue
Else
GetReportPath = vbNullChar
End If
ErrGetSectionentry:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Function