Public Function GetOpenFileNameGs( _
objForm As Form, _
Optional sInitialDir As String, _
Optional lFlag As Long = 0, _
Optional sFileFilter As String = mcsDefaultFileFilter _
) As String
If CurrentProject.AllForms("frmToDoListEntry").IsLoaded Then
sInitialDir = Forms!frmTodoListEntry!frmToDoListEntryLinks.Form.filelocation
ElseIf CurrentProject.AllForms("frmSubmittalEntry").IsLoaded Then
sInitialDir = Forms!frmSubmittalEntry!frmToDoListEntryLinks.Form.filelocation & "\Submittals"
ElseIf CurrentProject.AllForms("frmRFIInput").IsLoaded Then
sInitialDir = Forms!frmRFIInput.Form.filelocation & "\RFI"
ElseIf CurrentProject.AllForms("frmDailyReportReviewInput").IsLoaded Then
sInitialDir = "X:\MPOC\Daily Reports_Inspections Reports"
Else
sInitialDir = "C:\"
End If
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hWndOwner = objForm.Hwnd
OpenFile.hInstance = Application.hWndAccessApp
OpenFile.lpstrFilter = ReplaceG(sFileFilter, "|", vbNullChar)
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = sInitialDir
OpenFile.lpstrTitle = "Open File"
OpenFile.flags = lFlag
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
GetOpenFileNameGs = ""
Else
GetOpenFileNameGs = CleanStringMs(OpenFile.lpstrFile & "")
End If
End Function