Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    With the following code I

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Perhaps there are hidden trailing characters in Me.strAttachment. Change
    <code>
    MsgBox "sName: " & sName
    </code>
    to
    <code>
    MsgBox "sName: " & sName & "***"
    </code>
    Do you see anything between the extension and *** in the second example?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    MsgBox "sName: " & sName & "***" returned the same value above as MsgBox "sName: " & sName

    However, I

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    We'd have to know how cdlg works.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Does this help?

    <pre>Dim cdlg As New CommonDialogAPI
    Dim lngFormName As Long
    Dim lngAppInstance As Long
    Dim strInitDir As String
    Dim strFileFilter As String
    Dim lngResult As Long

    lngFormName = Me.hWnd
    lngAppInstance = Application.hWndAccessApp
    strInitDir = GetDirectoryPath("Snapshot")
    strFileFilter = "Snapshot Files (*.snp)" & Chr(0) & "*.snp" & Chr(0) & _
    "PDF Files (*.pdf)" & Chr(0) & "*.pdf" & Chr(0)

    lngResult = cdlg.OpenFileDialog(lngFormName, lngAppInstance, _
    strInitDir, strFileFilter)

    If cdlg.GetStatus = True Then
    Me.strAttachment = Trim(cdlg.GetName)
    Else
    MsgBox "No file selected."
    End If
    </pre>




    <pre>Public Function OpenFileDialog(lngFormHwnd As Long, _
    lngAppInstance As Long, strInitDir As String, _
    strFileFilter As String) As Long

    Dim OpenFile As OpenFilename
    Dim X As Long

    With OpenFile
    .lStructSize = Len(OpenFile)
    .hwndOwner = lngFormHwnd
    .hInstance = lngAppInstance
    .lpstrFilter = strFileFilter
    .nFilterIndex = 1
    .lpstrFile = String(255, 0)
    .nMaxFile = Len(OpenFile.lpstrFile) - 1
    .lpstrFileTitle = OpenFile.lpstrFile
    .nMaxFileTitle = OpenFile.nMaxFile
    .lpstrInitialDir = strInitDir
    .lpstrTitle = "Open File"
    .Flags = 0
    End With

    X = GetOpenFileName(OpenFile)
    If X = 0 Then
    mstrFileName = "none"
    mblnStatus = False
    Else
    mstrFileName = Trim(OpenFile.lpstrFile)
    mblnStatus = True
    End If
    End Function
    </pre>


  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Your filename string probably contains trailing null characters. Try changing the line

    mstrFileName = Trim(OpenFile.lpstrFile)

    to

    mstrFileName = Left(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, vbNullChar) - 1)

  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help With String Function? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    That got it, I was ready to report back with:

    Additional information

    MsgBox "Len(sName) - 3: " & Len(sName)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •