Import CSV from Open Dialog box Confirmation

Hi. I got my command button to bring up an open dialog box, where the
user will select the CSV file to be imported.

After the user finds the file to be imported, I want a MsgBox that
asks the user to confirm that the specific file be imported. For
example, the user selects SCO.csv to import and clicks a okay. A
Msgbox should popup "Are you sure you want to import SCO.csv" with a
Yes button and a No button. I'm not sure if this is even possible, but
if so could someone please guide me. If they click No, then the
process should just cancel.

0
shmoussa
5/23/2007 7:49:24 PM
access.formscoding 7493 articles. 0 followers. Follow

12 Replies
1195 Views

Similar Articles

[PageSpeed] 38

Assume strFileName is the variable with the file name to import.  I don't 
know how you are calling an open dialog. I use an API version, so I will show 
you this using the API.

    Do While True
        varGetFileName = ahtCommonFileOpenSave(ahtOFN_OVERWRITEPROMPT, _
            "\\rsltx1-bm01\busmgmt\Vought " & Me.txtCurrYear & "\Pipeline\", _
            "Excel Spreadsheets (*.xls) *.xls", , _
            "xls", Me!txtCurrYear & " " & Left(Me!cboPeriod.Column(1), 3) _
            & " Pipeline.xls", "Select Pipeline", , True)
        If varGetFileName = "" Then
            If MsgBox("Cancel Import?", vbQuestion + vbYesNo, "Import 
PipeLine") _
                    = vbYes Then
                Exit Sub
            End If
        Else
            lfMsgBox("Do you Want to Import " & varGetFileName, _
                vbQuestion + vbYesNo) = vbNo Then
                    Exit Sub
            Else
                Exit Do
        End If
    Loop


-- 
Dave Hargis, Microsoft Access MVP


"shmoussa" wrote:

> Hi. I got my command button to bring up an open dialog box, where the
> user will select the CSV file to be imported.
> 
> After the user finds the file to be imported, I want a MsgBox that
> asks the user to confirm that the specific file be imported. For
> example, the user selects SCO.csv to import and clicks a okay. A
> Msgbox should popup "Are you sure you want to import SCO.csv" with a
> Yes button and a No button. I'm not sure if this is even possible, but
> if so could someone please guide me. If they click No, then the
> process should just cancel.
> 
> 
0
Utf
5/23/2007 8:55:02 PM
Thank you for all of your replies. I called an open dialog by creating
a new module and pasting this code into it:

***********************************************************
Option Compare Database
Option Explicit

' Declarations for Windows Common Dialogs procedures
Private Type CLTAPI_OPENFILE
  strFilter As String             ' Filter string
  intFilterIndex As Long          ' Initial Filter to display.
  strInitialDir As String         ' Initial directory for the dialog
to open in.
  strInitialFile As String        ' Initial file name to populate the
dialog with.
  strDialogTitle As String        ' Dialog title
  strDefaultExtension As String   ' Default extension to append to
file if user didn't specify one.
  lngFlags As Long                ' Flags (see constant list) to be
used.
  strFullPathReturned As String   ' Full path of file picked.
  strFileNameReturned As String   ' File name of file picked.
  intFileOffset As Integer        ' Offset in full path
(strFullPathReturned) where the file name (strFileNameReturned)
begins.
  intFileExtension As Integer     ' Offset in full path
(strFullPathReturned) where the file extension begins.
End Type

Const ALLFILES = "All Files"

Private Type CLTAPI_WINOPENFILENAME
    lStructSize As Long
    hWndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustrFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    Flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustrData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type

Const OFN_ALLOWMULTISELECT = &H200
Const OFN_CREATEPROMPT = &H2000
Const OFN_EXPLORER = &H80000
Const OFN_FILEMUSTEXIST = &H1000
Const OFN_HIDEREADONLY = &H4
Const OFN_NOCHANGEDIR = &H8
Const OFN_NODEREFERENCELINKS = &H100000
Const OFN_NONETWORKBUTTON = &H20000
Const OFN_NOREADONLYRETURN = &H8000
Const OFN_NOVALIDATE = &H100
Const OFN_OVERWRITEPROMPT = &H2
Const OFN_PATHMUSTEXIST = &H800
Const OFN_READONLY = &H1
Const OFN_SHOWHELP = &H10

Declare Function CLTAPI_GetOpenFileName Lib "comdlg32.dll" Alias
"GetOpenFileNameA" _
  (pOpenfilename As CLTAPI_WINOPENFILENAME) _
As Boolean

Declare Function CLTAPI_GetSaveFileName Lib "comdlg32.dll" Alias
"GetSaveFileNameA" _
  (pOpenfilename As CLTAPI_WINOPENFILENAME) _
As Boolean

Declare Sub CLTAPI_ChooseColor Lib "msaccess.exe" Alias "#53" _
  (ByVal hwnd As Long, rgb As Long)

Function GetOpenFile_CLT(strInitialDir As String, strTitle As String)
As String
  ' Comments  : Simple file open routine. For additional options, use
GetFileOpenEX_CLT()
  ' Parameters: strInitialDir - path for the initial directory, or
blank for the current directory
  '             strTitle - title for the dialog
  ' Returns   : string path, name and extension of the file selected
  '
  Dim fOK As Boolean
  Dim typWinOpen As CLTAPI_WINOPENFILENAME
  Dim typOpenFile As CLTAPI_OPENFILE
  Dim strFilter As String

  On Error GoTo PROC_ERR

  ' Set defaults for the structure
  strFilter = CreateFilterString_CLT("CSV Files (*.csv)", "*.csv",
"All Files (*.*)", "*.*")

  If strInitialDir <> "" Then
    typOpenFile.strInitialDir = strInitialDir
  Else
    typOpenFile.strInitialDir = CurDir()
  End If

  If strTitle <> "" Then
    typOpenFile.strDialogTitle = strTitle
  End If

  typOpenFile.strFilter = strFilter
  typOpenFile.lngFlags = OFN_HIDEREADONLY Or OFN_SHOWHELP

  ' Convert the CLT structure to a Win structure
  ConvertCLT2Win typOpenFile, typWinOpen

  ' Call the Common dialog
  fOK = CLTAPI_GetOpenFileName(typWinOpen)

  ' Convert the Win structure back to a CLT structure
  ConvertWin2CLT typWinOpen, typOpenFile

  GetOpenFile_CLT = typOpenFile.strFullPathReturned

PROC_EXIT:
  Exit Function

PROC_ERR:
  GetOpenFile_CLT = ""
  Resume PROC_EXIT

End Function

Sub ConvertCLT2Win(CLT_Struct As CLTAPI_OPENFILE, Win_Struct As
CLTAPI_WINOPENFILENAME)
  ' Comments  : Converts the passed CLTAPI structure to a Windows
structure
  ' Parameters: CLT_Struct - record of type CLTAPI_OPENFILE
  '             Win_Struct - record of type CLTAPI_WINOPENFILENAME
  ' Returns   : Nothing
  '
  Dim strFile As String * 512

  On Error GoTo PROC_ERR

  Win_Struct.hWndOwner = Application.hWndAccessApp
  Win_Struct.hInstance = 0

  If CLT_Struct.strFilter = "" Then
    Win_Struct.lpstrFilter = ALLFILES & Chr$(0) & "*.*" & Chr$(0)
  Else
    Win_Struct.lpstrFilter = CLT_Struct.strFilter
  End If
  Win_Struct.nFilterIndex = CLT_Struct.intFilterIndex

  Win_Struct.lpstrFile = String(512, 0)
  Win_Struct.nMaxFile = 511

  Win_Struct.lpstrFileTitle = String$(512, 0)
  Win_Struct.nMaxFileTitle = 511

  Win_Struct.lpstrTitle = CLT_Struct.strDialogTitle
  Win_Struct.lpstrInitialDir = CLT_Struct.strInitialDir
  Win_Struct.lpstrDefExt = CLT_Struct.strDefaultExtension

  Win_Struct.Flags = CLT_Struct.lngFlags

  Win_Struct.lStructSize = Len(Win_Struct)

PROC_EXIT:
  Exit Sub

PROC_ERR:
  Resume PROC_EXIT

End Sub

Sub ConvertWin2CLT(Win_Struct As CLTAPI_WINOPENFILENAME, CLT_Struct As
CLTAPI_OPENFILE)
  ' Comments  : Converts the passed CLTAPI structure to a Windows
structure
  ' Parameters: Win_Struct - record of type CLTAPI_WINOPENFILENAME
  '             CLT_Struct - record of type CLTAPI_OPENFILE
  ' Returns   : Nothing
  '
  On Error GoTo PROC_ERR

  CLT_Struct.strFullPathReturned = Left(Win_Struct.lpstrFile,
InStr(Win_Struct.lpstrFile, vbNullChar) - 1)
  CLT_Struct.strFileNameReturned =
RemoveNulls_CLT(Win_Struct.lpstrFileTitle)
  CLT_Struct.intFileOffset = Win_Struct.nFileOffset
  CLT_Struct.intFileExtension = Win_Struct.nFileExtension

PROC_EXIT:
  Exit Sub

PROC_ERR:
  Resume PROC_EXIT

End Sub

Function CreateFilterString_CLT(ParamArray varFilt() As Variant) As
String
  ' Comments  : Builds a Windows formatted filter string for "file
type"
  ' Parameters: varFilter - parameter array in the format:
  '                          Text, Filter, Text, Filter ...
  '                         Such as:
  '                          "All Files (*.*)", "*.*", "Text Files
(*.TXT)", "*.TXT"
  ' Returns   : windows formatted filter string
  '
  Dim strFilter As String
  Dim intCounter As Integer
  Dim intParamCount As Integer

  On Error GoTo PROC_ERR

  ' Get the count of paramaters passed to the function
  intParamCount = UBound(varFilt)

  If (intParamCount <> -1) Then

    ' Count through each parameter
    For intCounter = 0 To intParamCount
      strFilter = strFilter & varFilt(intCounter) & Chr$(0)
    Next

    ' Check for an even number of parameters
    If (intParamCount Mod 2) = 0 Then
      strFilter = strFilter & "*.*" & Chr$(0)
    End If

  End If

  CreateFilterString_CLT = strFilter

PROC_EXIT:
  Exit Function

PROC_ERR:
  CreateFilterString_CLT = ""
  Resume PROC_EXIT

End Function

Function RemoveNulls_CLT(strIn As String) As String
  ' Comments  : Removes terminator from a string
  ' Parameters: strIn - string to modify
  ' Return    : modified string
  '
  Dim intChr As Integer

  intChr = InStr(strIn, Chr$(0))

  If intChr > 0 Then
    RemoveNulls_CLT = Left$(strIn, intChr - 1)
  Else
    RemoveNulls_CLT = strIn
  End If

End Function
******************************************************************************************
Then, pasted this code onto my command button:

Private Sub cmdOpenFile_Click()
On Error GoTo err_cmdOpenFile_Click

  Dim strFile As String

  strFile = GetOpenFile_CLT("C:\Disk Space", "Select the .csv file
that you want to import")

exit_cmdOpenFile_Click:
    Exit Sub

err_cmdOpenFile_Click:
    MsgBox Err.Description
    Resume exit_cmdOpenFile_Click

End Sub
**************************************************************************************

Would you please tell me where to put your code and what exactly I
need to change? I appreciate it. Thank you.

0
shmoussa
5/24/2007 2:50:46 PM
It would go in the Click event of your command button.
You should be able to figure out what needs to be changed.  The only thing 
different is the call to the open dialog.

-- 
Dave Hargis, Microsoft Access MVP


"shmoussa" wrote:

> Thank you for all of your replies. I called an open dialog by creating
> a new module and pasting this code into it:
> 
> ***********************************************************
> Option Compare Database
> Option Explicit
> 
> ' Declarations for Windows Common Dialogs procedures
> Private Type CLTAPI_OPENFILE
>   strFilter As String             ' Filter string
>   intFilterIndex As Long          ' Initial Filter to display.
>   strInitialDir As String         ' Initial directory for the dialog
> to open in.
>   strInitialFile As String        ' Initial file name to populate the
> dialog with.
>   strDialogTitle As String        ' Dialog title
>   strDefaultExtension As String   ' Default extension to append to
> file if user didn't specify one.
>   lngFlags As Long                ' Flags (see constant list) to be
> used.
>   strFullPathReturned As String   ' Full path of file picked.
>   strFileNameReturned As String   ' File name of file picked.
>   intFileOffset As Integer        ' Offset in full path
> (strFullPathReturned) where the file name (strFileNameReturned)
> begins.
>   intFileExtension As Integer     ' Offset in full path
> (strFullPathReturned) where the file extension begins.
> End Type
> 
> Const ALLFILES = "All Files"
> 
> Private Type CLTAPI_WINOPENFILENAME
>     lStructSize As Long
>     hWndOwner As Long
>     hInstance As Long
>     lpstrFilter As String
>     lpstrCustomFilter As String
>     nMaxCustrFilter As Long
>     nFilterIndex As Long
>     lpstrFile As String
>     nMaxFile As Long
>     lpstrFileTitle As String
>     nMaxFileTitle As Long
>     lpstrInitialDir As String
>     lpstrTitle As String
>     Flags As Long
>     nFileOffset As Integer
>     nFileExtension As Integer
>     lpstrDefExt As String
>     lCustrData As Long
>     lpfnHook As Long
>     lpTemplateName As String
> End Type
> 
> Const OFN_ALLOWMULTISELECT = &H200
> Const OFN_CREATEPROMPT = &H2000
> Const OFN_EXPLORER = &H80000
> Const OFN_FILEMUSTEXIST = &H1000
> Const OFN_HIDEREADONLY = &H4
> Const OFN_NOCHANGEDIR = &H8
> Const OFN_NODEREFERENCELINKS = &H100000
> Const OFN_NONETWORKBUTTON = &H20000
> Const OFN_NOREADONLYRETURN = &H8000
> Const OFN_NOVALIDATE = &H100
> Const OFN_OVERWRITEPROMPT = &H2
> Const OFN_PATHMUSTEXIST = &H800
> Const OFN_READONLY = &H1
> Const OFN_SHOWHELP = &H10
> 
> Declare Function CLTAPI_GetOpenFileName Lib "comdlg32.dll" Alias
> "GetOpenFileNameA" _
>   (pOpenfilename As CLTAPI_WINOPENFILENAME) _
> As Boolean
> 
> Declare Function CLTAPI_GetSaveFileName Lib "comdlg32.dll" Alias
> "GetSaveFileNameA" _
>   (pOpenfilename As CLTAPI_WINOPENFILENAME) _
> As Boolean
> 
> Declare Sub CLTAPI_ChooseColor Lib "msaccess.exe" Alias "#53" _
>   (ByVal hwnd As Long, rgb As Long)
> 
> Function GetOpenFile_CLT(strInitialDir As String, strTitle As String)
> As String
>   ' Comments  : Simple file open routine. For additional options, use
> GetFileOpenEX_CLT()
>   ' Parameters: strInitialDir - path for the initial directory, or
> blank for the current directory
>   '             strTitle - title for the dialog
>   ' Returns   : string path, name and extension of the file selected
>   '
>   Dim fOK As Boolean
>   Dim typWinOpen As CLTAPI_WINOPENFILENAME
>   Dim typOpenFile As CLTAPI_OPENFILE
>   Dim strFilter As String
> 
>   On Error GoTo PROC_ERR
> 
>   ' Set defaults for the structure
>   strFilter = CreateFilterString_CLT("CSV Files (*.csv)", "*.csv",
> "All Files (*.*)", "*.*")
> 
>   If strInitialDir <> "" Then
>     typOpenFile.strInitialDir = strInitialDir
>   Else
>     typOpenFile.strInitialDir = CurDir()
>   End If
> 
>   If strTitle <> "" Then
>     typOpenFile.strDialogTitle = strTitle
>   End If
> 
>   typOpenFile.strFilter = strFilter
>   typOpenFile.lngFlags = OFN_HIDEREADONLY Or OFN_SHOWHELP
> 
>   ' Convert the CLT structure to a Win structure
>   ConvertCLT2Win typOpenFile, typWinOpen
> 
>   ' Call the Common dialog
>   fOK = CLTAPI_GetOpenFileName(typWinOpen)
> 
>   ' Convert the Win structure back to a CLT structure
>   ConvertWin2CLT typWinOpen, typOpenFile
> 
>   GetOpenFile_CLT = typOpenFile.strFullPathReturned
> 
> PROC_EXIT:
>   Exit Function
> 
> PROC_ERR:
>   GetOpenFile_CLT = ""
>   Resume PROC_EXIT
> 
> End Function
> 
> Sub ConvertCLT2Win(CLT_Struct As CLTAPI_OPENFILE, Win_Struct As
> CLTAPI_WINOPENFILENAME)
>   ' Comments  : Converts the passed CLTAPI structure to a Windows
> structure
>   ' Parameters: CLT_Struct - record of type CLTAPI_OPENFILE
>   '             Win_Struct - record of type CLTAPI_WINOPENFILENAME
>   ' Returns   : Nothing
>   '
>   Dim strFile As String * 512
> 
>   On Error GoTo PROC_ERR
> 
>   Win_Struct.hWndOwner = Application.hWndAccessApp
>   Win_Struct.hInstance = 0
> 
>   If CLT_Struct.strFilter = "" Then
>     Win_Struct.lpstrFilter = ALLFILES & Chr$(0) & "*.*" & Chr$(0)
>   Else
>     Win_Struct.lpstrFilter = CLT_Struct.strFilter
>   End If
>   Win_Struct.nFilterIndex = CLT_Struct.intFilterIndex
> 
>   Win_Struct.lpstrFile = String(512, 0)
>   Win_Struct.nMaxFile = 511
> 
>   Win_Struct.lpstrFileTitle = String$(512, 0)
>   Win_Struct.nMaxFileTitle = 511
> 
>   Win_Struct.lpstrTitle = CLT_Struct.strDialogTitle
>   Win_Struct.lpstrInitialDir = CLT_Struct.strInitialDir
>   Win_Struct.lpstrDefExt = CLT_Struct.strDefaultExtension
> 
>   Win_Struct.Flags = CLT_Struct.lngFlags
> 
>   Win_Struct.lStructSize = Len(Win_Struct)
> 
> PROC_EXIT:
>   Exit Sub
> 
> PROC_ERR:
>   Resume PROC_EXIT
> 
> End Sub
> 
> Sub ConvertWin2CLT(Win_Struct As CLTAPI_WINOPENFILENAME, CLT_Struct As
> CLTAPI_OPENFILE)
>   ' Comments  : Converts the passed CLTAPI structure to a Windows
> structure
>   ' Parameters: Win_Struct - record of type CLTAPI_WINOPENFILENAME
>   '             CLT_Struct - record of type CLTAPI_OPENFILE
>   ' Returns   : Nothing
>   '
>   On Error GoTo PROC_ERR
> 
>   CLT_Struct.strFullPathReturned = Left(Win_Struct.lpstrFile,
> InStr(Win_Struct.lpstrFile, vbNullChar) - 1)
>   CLT_Struct.strFileNameReturned =
> RemoveNulls_CLT(Win_Struct.lpstrFileTitle)
>   CLT_Struct.intFileOffset = Win_Struct.nFileOffset
>   CLT_Struct.intFileExtension = Win_Struct.nFileExtension
> 
> PROC_EXIT:
>   Exit Sub
> 
> PROC_ERR:
>   Resume PROC_EXIT
> 
> End Sub
> 
> Function CreateFilterString_CLT(ParamArray varFilt() As Variant) As
> String
>   ' Comments  : Builds a Windows formatted filter string for "file
> type"
>   ' Parameters: varFilter - parameter array in the format:
>   '                          Text, Filter, Text, Filter ...
>   '                         Such as:
>   '                          "All Files (*.*)", "*.*", "Text Files
> (*.TXT)", "*.TXT"
>   ' Returns   : windows formatted filter string
>   '
>   Dim strFilter As String
>   Dim intCounter As Integer
>   Dim intParamCount As Integer
> 
>   On Error GoTo PROC_ERR
> 
>   ' Get the count of paramaters passed to the function
>   intParamCount = UBound(varFilt)
> 
>   If (intParamCount <> -1) Then
> 
>     ' Count through each parameter
>     For intCounter = 0 To intParamCount
>       strFilter = strFilter & varFilt(intCounter) & Chr$(0)
>     Next
> 
>     ' Check for an even number of parameters
>     If (intParamCount Mod 2) = 0 Then
>       strFilter = strFilter & "*.*" & Chr$(0)
>     End If
> 
>   End If
> 
>   CreateFilterString_CLT = strFilter
> 
> PROC_EXIT:
>   Exit Function
> 
> PROC_ERR:
>   CreateFilterString_CLT = ""
>   Resume PROC_EXIT
> 
> End Function
> 
> Function RemoveNulls_CLT(strIn As String) As String
>   ' Comments  : Removes terminator from a string
>   ' Parameters: strIn - string to modify
>   ' Return    : modified string
>   '
>   Dim intChr As Integer
> 
>   intChr = InStr(strIn, Chr$(0))
> 
>   If intChr > 0 Then
>     RemoveNulls_CLT = Left$(strIn, intChr - 1)
>   Else
>     RemoveNulls_CLT = strIn
>   End If
> 
> End Function
> ******************************************************************************************
> Then, pasted this code onto my command button:
> 
> Private Sub cmdOpenFile_Click()
> On Error GoTo err_cmdOpenFile_Click
> 
>   Dim strFile As String
> 
>   strFile = GetOpenFile_CLT("C:\Disk Space", "Select the .csv file
> that you want to import")
> 
> exit_cmdOpenFile_Click:
>     Exit Sub
> 
> err_cmdOpenFile_Click:
>     MsgBox Err.Description
>     Resume exit_cmdOpenFile_Click
> 
> End Sub
> **************************************************************************************
> 
> Would you please tell me where to put your code and what exactly I
> need to change? I appreciate it. Thank you.
> 
> 
0
Utf
5/24/2007 2:59:02 PM
I really appreciate your help. Now, I took that code and from what I
can tell, it looks like it is calling the open dialog box? I already
have that part working. I tried to work with what you gave me and came
up with this:

************************************************************
Private Sub cmdOpenFile_Click()
On Error GoTo err_cmdOpenFile_Click
Dim vbQuestion As String
Dim vbYesNo As String
Dim vbNo As String
Dim vbYes As String

  Dim strFile As String

  strFile = GetOpenFile_CLT("M:\CSO SERVER SUPPORT\Novell\Disk Space",
"Select the .csv file that you want to import")



 If strFile = "" Then
        If MsgBox(("Cancel Import?"), vbQuestion + vbYesNo, "Import
PipeLine" = vbYes) Then
        Exit Sub
            End If
        Else
        If MsgBox("Do you Want to Import " & strFile, vbQuestion +
vbYesNo) = vbNo Then
                Exit Sub
            Else
        End If
        End If



  DoCmd.TransferText acImportDelim, DISKS, TableNew, strFile, True

exit_cmdOpenFile_Click:
    Exit Sub

err_cmdOpenFile_Click:
    MsgBox Err.Number & " " & Err.Description
    Resume exit_cmdOpenFile_Click

End Sub

**********************************************************************

I get an error "Type 13 mismatch." I'm sorry if I did this wrong- I am
pretty new to VB and am learning a great deal with everyone's help.
Please help me figure this out. I appreciate it.

0
shmoussa
5/24/2007 4:17:21 PM
It would be helpful to know on exaclty which line you get the error.
-- 
Dave Hargis, Microsoft Access MVP


"shmoussa" wrote:

> I really appreciate your help. Now, I took that code and from what I
> can tell, it looks like it is calling the open dialog box? I already
> have that part working. I tried to work with what you gave me and came
> up with this:
> 
> ************************************************************
> Private Sub cmdOpenFile_Click()
> On Error GoTo err_cmdOpenFile_Click
> Dim vbQuestion As String
> Dim vbYesNo As String
> Dim vbNo As String
> Dim vbYes As String
> 
>   Dim strFile As String
> 
>   strFile = GetOpenFile_CLT("M:\CSO SERVER SUPPORT\Novell\Disk Space",
> "Select the .csv file that you want to import")
> 
> 
> 
>  If strFile = "" Then
>         If MsgBox(("Cancel Import?"), vbQuestion + vbYesNo, "Import
> PipeLine" = vbYes) Then
>         Exit Sub
>             End If
>         Else
>         If MsgBox("Do you Want to Import " & strFile, vbQuestion +
> vbYesNo) = vbNo Then
>                 Exit Sub
>             Else
>         End If
>         End If
> 
> 
> 
>   DoCmd.TransferText acImportDelim, DISKS, TableNew, strFile, True
> 
> exit_cmdOpenFile_Click:
>     Exit Sub
> 
> err_cmdOpenFile_Click:
>     MsgBox Err.Number & " " & Err.Description
>     Resume exit_cmdOpenFile_Click
> 
> End Sub
> 
> **********************************************************************
> 
> I get an error "Type 13 mismatch." I'm sorry if I did this wrong- I am
> pretty new to VB and am learning a great deal with everyone's help.
> Please help me figure this out. I appreciate it.
> 
> 
0
Utf
5/24/2007 4:25:00 PM
Okay This is probably the problem.
> Dim vbQuestion As String
> Dim vbYesNo As String
> Dim vbNo As String
> Dim vbYes As String

You don't need to Dim these.  They are intrinsic (built in) constants in VB 
and all are actually Long data types, but again you don't need to Dim them.
-- 
Dave Hargis, Microsoft Access MVP


"shmoussa" wrote:

> I really appreciate your help. Now, I took that code and from what I
> can tell, it looks like it is calling the open dialog box? I already
> have that part working. I tried to work with what you gave me and came
> up with this:
> 
> ************************************************************
> Private Sub cmdOpenFile_Click()
> On Error GoTo err_cmdOpenFile_Click
> Dim vbQuestion As String
> Dim vbYesNo As String
> Dim vbNo As String
> Dim vbYes As String
> 
>   Dim strFile As String
> 
>   strFile = GetOpenFile_CLT("M:\CSO SERVER SUPPORT\Novell\Disk Space",
> "Select the .csv file that you want to import")
> 
> 
> 
>  If strFile = "" Then
>         If MsgBox(("Cancel Import?"), vbQuestion + vbYesNo, "Import
> PipeLine" = vbYes) Then
>         Exit Sub
>             End If
>         Else
>         If MsgBox("Do you Want to Import " & strFile, vbQuestion +
> vbYesNo) = vbNo Then
>                 Exit Sub
>             Else
>         End If
>         End If
> 
> 
> 
>   DoCmd.TransferText acImportDelim, DISKS, TableNew, strFile, True
> 
> exit_cmdOpenFile_Click:
>     Exit Sub
> 
> err_cmdOpenFile_Click:
>     MsgBox Err.Number & " " & Err.Description
>     Resume exit_cmdOpenFile_Click
> 
> End Sub
> 
> **********************************************************************
> 
> I get an error "Type 13 mismatch." I'm sorry if I did this wrong- I am
> pretty new to VB and am learning a great deal with everyone's help.
> Please help me figure this out. I appreciate it.
> 
> 
0
Utf
5/24/2007 4:27:00 PM
I got rid of all of the DIMS, and it gives me "Compile Error: syntax
error" on this line:


        If MsgBox(("Cancel Import?"), vbQuestion + vbYesNo, "Import

Any idea?

0
shmoussa
5/24/2007 5:03:48 PM
Private Sub cmdOpenFile_Click()
On Error GoTo err_cmdOpenFile_Click

  Dim strFile As String

  strFile = GetOpenFile_CLT("C:\Disk Space", "Select the .csv file
that you want to import")

If strFile = "" Then
If MsgBox("Cancel Import?", vbQuestion + vbYesNo, "Import Disk Data" =
vbYes) Then
        Exit Sub
            End If
        Else
If MsgBox("Do you Want to Import " & strFile, vbQuestion + vbYesNo,
"Import Disk Data" = vbNo) Then
        Exit Sub
            Else
        End If
        End If

  DoCmd.TransferText acImportDelim, "DISKS", "TableNew", strFile, True

exit_cmdOpenFile_Click:
    Exit Sub

err_cmdOpenFile_Click:
    MsgBox Err.Number & " " & Err.Description
    Resume exit_cmdOpenFile_Click

End Sub
******************************************************************************************


This gives me error 13: Type Mismatch. Can't find what is wrong.
Please help.

0
shmoussa
5/24/2007 6:32:16 PM
Oops, sorry I gave the wrong syntax, this should do it.
If you still have an error, please let me know which line the error occurs on.

If MsgBox("Cancel Import?", vbQuestion + vbYesNo, "Import
PipeLine") = vbYes Then
-- 
Dave Hargis, Microsoft Access MVP


"shmoussa" wrote:

> Private Sub cmdOpenFile_Click()
> On Error GoTo err_cmdOpenFile_Click
> 
>   Dim strFile As String
> 
>   strFile = GetOpenFile_CLT("C:\Disk Space", "Select the .csv file
> that you want to import")
> 
> If strFile = "" Then
> If MsgBox("Cancel Import?", vbQuestion + vbYesNo, "Import Disk Data" =
> vbYes) Then
>         Exit Sub
>             End If
>         Else
> If MsgBox("Do you Want to Import " & strFile, vbQuestion + vbYesNo,
> "Import Disk Data" = vbNo) Then
>         Exit Sub
>             Else
>         End If
>         End If
> 
>   DoCmd.TransferText acImportDelim, "DISKS", "TableNew", strFile, True
> 
> exit_cmdOpenFile_Click:
>     Exit Sub
> 
> err_cmdOpenFile_Click:
>     MsgBox Err.Number & " " & Err.Description
>     Resume exit_cmdOpenFile_Click
> 
> End Sub
> ******************************************************************************************
> 
> 
> This gives me error 13: Type Mismatch. Can't find what is wrong.
> Please help.
> 
> 
0
Utf
5/24/2007 6:46:01 PM
PERFECT THANK YOU!!! IT WORKS. Okay there a couple more questions I
may be posting in a bit, if I can't figure it out. Thanks again.

0
shmoussa
5/24/2007 7:16:18 PM
Okay I lied. Not perfect yet. If I close the open box, it asks me if I
want to cancel. If I click yes, it cancels. If I click no, I get this
error : "2522 The action or method requires a file name arguement."

Here's the code:

Private Sub cmdOpenFile_Click()
On Error GoTo err_cmdOpenFile_Click

  Dim strFile As String

  strFile = GetOpenFile_CLT("C:\Disk Space", "Select the .csv file
that you want to import")

If strFile = "" Then
If MsgBox("Cancel Import?", vbQuestion + vbYesNo, "Cancel Disk Data
Import ") = vbYes Then
        Exit Sub
            End If
       Else
If MsgBox("Are you sure you want to add the following file to your
disk data: " & strFile, vbQuestion + vbYesNo, "Import Disk Data") =
vbNo Then
        Exit Sub
            Else
        End If
        End If


  DoCmd.TransferText acImportDelim, "DISKS", "TableNew", strFile, True

exit_cmdOpenFile_Click:
    Exit Sub

err_cmdOpenFile_Click:
    MsgBox Err.Number & " " & Err.Description
    Resume exit_cmdOpenFile_Click

End Sub

******************************************

How can I tell it to reopen the dialog box if I click no to cancelling
the process?? Thank you.

0
shmoussa
5/24/2007 7:26:09 PM
Okay. forget it again. I just took out the cancel confirmation all
together and it works fine now.

0
shmoussa
5/24/2007 7:48:12 PM
Reply:

Similar Artilces:

Pop Up Combo Box
I have 3 options in a combo: TS, CT, and MISC Each one of these options has their own pertinent account codes. What I want is the ability to choose one of the options (TS, CT or MISC), and based on that choice, have another combo box pop up with a list of corresponding account codes. If you can help with step-by-step moron-proof instructions, I would be much obliged. This is called "cascading combo boxes". A google search should return plenty of links that will show you how to do it. HTH -- _________ Sean Bailey "natalie" wrote: > I have 3 options in a combo...

moving payables data from open to history
Hello: A client says that someone imported data about a year or two ago into Great Plains from their AS400. Many payables documents that were imported should have been coded during the import as open, instead of history. The client knows that she can take care of this herself within two hours, by simply turning off the posting to the GL and entering and posting the payables documents to move them to history. But, she is wondering if there is a quick and easy way to do this on the back-end. I'm familiar with the open and history payables tables within GP. And, I know through a T...

SharePoint (WSS) 2007 / Outlook 2007 - Alert
This is a multi-part message in MIME format. ------=_NextPart_000_00AD_01C70E47.83B45950 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable We have setup a SharePoint Server (WSS) 2007 and are using the alerting = functionality. After we changes stuff on WSS, an alert message is generated and sent to = an email account. This e-mail account is hosted on an Exchange 2003 server. When using Outlook 2007 to open the e-mail, we get: Cannot open this item. Wenn using OWA the e-mail can be opene fine. Does somehow have an explanation for th...

selected row count of list box
A2k Is there a way to get the selected row count of a list box dynamically as the user selects rows? Delphi has an event called "OnSelectionChanged" but Access is much more limited. I don't want the user to have to exit the list box or click a button or anything manual in order to see the # of rows he's selected. How can this be done? I know about "lstCusts.ItemsSelected.Count" but not sure what event to use it in to accomplish what I need. Thanks, Keith Never mind. I did this and it handles both mouse and keyboard selections: Private Sub lstCusts_AfterUpdat...

disable Review toolbar which came up automatically when opening a.
How can I disable the Review Toolbar which comes up automatically when opening a file? In the Workbook VBA actions. The top left hand corner there is an Excel logo, not the one in th blue program bar, but in the menu bar. Right Click and select "View Code" There will be two drop down boxes one that will probably say General if this has never been entered previously. Change the box on the right to Workbook. Then Change the right hand box to "Activate" Insert the following code Application.CommandBars("Reviewing").Visible = False exit the VBA screen and t...

Importing spam list
Hi, I have a long list of spam email addresses that I want to import into outlook. How do I do this? Do they have to be separated by commas? Thaks, Paul Where is this spam list generated? What version of Outlook? Where do you propose to import them? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, Paul Ellis asked: | Hi, | I have a long list of spam email addresses...

Smartlist Export to CSV
I've notice when I try to save a file as tab or comma delimited, it still just comes out as a regular text file with no formatting. Only thing I can do is export to excel and then save to CSV. Is there a problem with this in GP 8? Try exporting to Excel and then saving in whatever format you want. David Musgrave [MSFT] Senior Development Consultant Escalation Engineer MBS Support - Asia Pacific Microsoft Business Solutions http://www.microsoft.com/BusinessSolutions mailto:dmusgrav@online.microsoft.com Any views contained within are my personal views and not necessarily Microsoft...

"the wizard is unable to open your query in datasheet mode, possi
"the wizard is unable to open your query in datasheet mode, possibly because another user has a source table open in exclusive mode. your query will be opened in design view" what this message mean ,and how can i solve it Hi - Please provide more details as to what you are doing when you get the error, what your database setup is (i.e. split Fe/BE?, multiuser?, version? etc). Without more information, we can only guess. Thanks - John amr wrote: >"the wizard is unable to open your query in datasheet mode, possibly because >another user has a ...

Excel 2000 vs. Excel 2002
I am having troubles with a workbook that I created that is havin problems opening. I created it in 2002, and it opens fine in Excel 2002 for other people However, when I send it to someone who has Excel 2000, it takes over a hour to open. Now I also made a very similar report that works just fine whe trasferred to excel 2000. Here are a couple of stats on the workbook that is having problems: 1.5mb 500+ externel links 500+ subtotals 200+ simple calculations (a1+b1; a1/b1;etc..) 1 Worksheet in the book. 2 columns with conditional formatting Thanks, Joh -- Message posted from http://ww...

Any FREAKIN' way to import DBX files into Outlook 2003
I've tried: Importing via Outlook | Import from another Program or File Importing via Outlook | Import Internet Mail and Addresses Exporting from Outlook Express Tried Many, many times... Can Microsucks make this any more complicated... It's a FREAKIN' DBX file collection NO - No other Application has it Open. YES - The Files ARE there YES - the Internet Account IS there Yes - I've wasted more of my time IMPORTING into Outlook Express in VISTA just to RE-EXPORT back to Outlook. What a bunch of freakin' idiots... Another 2 hours wasted - because one Microsoft applica...

Office 2004 issue with documents NOT BEING ABLE TO OPEN APPLICATION, but application can open documents.
BACKGROUND: Just migrated all my files and apps from a G4-400 to a new Mac Mini 1.87ghz Intel running pre-installed OSX10.4.10. Used CD to install 'normal' version of Office 2004 Mac on the new Mac Mini. In fact its the same disk that I used originally to install Office on the G4-400. PROBLEM: Neither old .xls and .doc documents (made on old Mac, nor new .xls and ..doc documents (made on new Mac)will not open their respective applications, when clicked upon. ADDITIONAL INFO: However, when I use either of the the application's "Open" feature, theres is no pr...

Import reg files into Registry, without UAC
Hi, I've got a .reg file to be imported silently in a batch. The file contains only entries in HKEY_CURRENT_USER, therefore can be imported without elevation. This works well with the regedit /s switch on limited accounts, however on admin accounts, elevation UAC prompt is still shown, even though it's not needed. How can I prevent this? Thanks, Jens Jens M�ller wrote: >Hi, > >I've got a .reg file to be imported silently in a batch. The file contains >only entries in HKEY_CURRENT_USER, therefore can be imported without >elevation. >...

Opening .prn files in XL2000
I am using a software that does not save data/reports in .csv or .xls formats; only in printed versions. Is there a way to save the printed report in a file and open the file in XL2000? If there is, how is the print file produced, where is it saved, etc? A friend suggested setting up a generic printer but didn't know how to go about it. You may want to give that other software just one more chance--look under File and see if there is a SaveAs option. You may find something upon further review. But if you want to add a generic printer, I think it'll depend on your version of win...

How do I import from LotusOrg 6.0?Import command only has 5.0
I am trying to import my calendar data from Lotus Org V6.X. Under the file command, it will only import from V5.X. Does anybody have any help for me since I would like to convert to Outlook from Lotus Organizer. Don Kiamie donalbert@mindspring.com In news:32C8F514-3EA5-4802-B1A4-F9C66E77293A@microsoft.com, DonAlbert <DonAlbert@discussions.microsoft.com> typed: > I am trying to import my calendar data from Lotus Org V6.X. Under > the file command, it will only import from V5.X. Does anybody have > any help for me since I would like to convert to Outlook from Lotus > ...

Trying to open the current db in Access 2010 through Access Basic
I haven't programmed in Access Basic in quite a long time. Through Access Basic coding, I use to be able to open the current database and then open a table and walk through each record. Now I can't even open the database. Does anybody have an example of how to do the following: 1) Open Workspace 2) Open Current Database (assume name is unknown during run time 3) Open specific table 4) Step through each record and access the fields George C. Derkacs <George C. Derkacs@discussions.microsoft.com> wrote: >I haven't programmed in Access Basic in quite a lon...

IF statement based on True/False that activates a certain list box
I've been asked to create a formula that will react to either "yes" or "no" entered into a cell which will show options in another cell based on a certain list. Example: Cells D3:D5 contain the values Monday, Tuesday, Wednesday (list named BegWeek) Cells E3:E5 contain the values Thursday, Friday, Saturday (list named EndWeek) Cell A3 accepts either "yes" or "no" entry only from a list If A3 = "Yes" then B3 will = drop down list BegWeek If A3 = "No" then B3 will = drop down list End Week I don't even know if thi...

How to import a list of links into Excel?
Does anyone have any suggestions on how to import a list of links in to Excel? Under the sheet "Date", there is a list of http links under column C, and a list of name under column B, I would like to import each link into specific sheet at cell A1. For example, in sheet "Date", there is a link www.cnn.com in cell C2, and 1 in cell B2, so this link is imported into sheet "1", and keep running the rest of links. Does anyone have any suggestions on how to do it in Excel macro? Thanks in advance for any suggestions Eric Hi Eric If you have numerics in...

Help
Hi... I tried to work on Word today for first time on newish Mac and realized none of my Office applications work. When I double click on Word I can see something happening as I get the circle of colours twirling, but half an hour later it still hadn't opened. I just have to do this as quickly as possible as I have a deadline for what I have to do Monday at 12. I've tried reinstalling the software, but that didn't do anything for me. Mind you I know absolutely nothing about installing anything on Mac computers so I could be doing it all wrong. Do any of you have any idea what c...

how can I draw a box and whisker plot in excel 2002?
I have some data, and have worked out the minimum value, the 1st and 3rd quartiles, the median and the maximum, but need to find out how to put this together in a box and whisker plot See http://peltiertech.com/Excel/Charts/BoxWhiskerH.html best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "andywilson" <andywilson@discussions.microsoft.com> wrote in message news:269E939E-6FC6-4993-BD6E-54ACE14141EB@microsoft.com... >I have some data, and have worked out the minimum value, the 1st and 3rd > quartiles, the median and the maximum, but ...

Need to show file properties dialog box
Hello I need to show the shell's file properties dialog box. I tried converting old vb6 code into vb.net but it gives me error. Here's my code: Private Structure SHELLEXECUTEINFO Dim cbSize As Long Dim fMask As Long Dim hwnd As Long Dim lpVerb As String Dim lpFile As String Dim lpParameters As String Dim lpDirectory As String Dim nShow As Long Dim hInstApp As Long Dim lpIDList As Long Dim lpClass As String Dim hkeyClass As Long Dim dwHotKey As Long D...

Text Box & Border Art
New Publisher 2003 user and getting quickly frustrated. I have setup a custom page size of 6.5" x 4.5" under Page Setup/Print Settings. I then created a text box of the same size, and filled it with the text I wanted. I then want to add a border to this text box. So, I right click on the text box, and choose Border Art under the Colors and Lines tab, and select the border "Twisted Lines" and hit apply. All is good. Now comes the trouble. I hit print preview and about 1/8" around the entire page is cutoff. All the margins are set to 0". I'm at a ...

How to delete stuck file from "All Junk e-mail" Box ?
How to delete stuck file from "All Junk e-mail" Box ? I'm using WLM on Win7. Thanks for any help. "Jdr" <omni@msn.net> wrote in message news:C2919371-6A82-4478-A411-8FEB13F66B41@microsoft.com... > How to delete stuck file from "All Junk e-mail" Box ? > I'm using WLM on Win7. Thanks for any help. try dragging it to the deleted folder. "c.d." <invalid@iglou.com> wrote in message news:es$OnIzzKHA.4384@TK2MSFTNGP06.phx.gbl... > > "Jdr" <omni@msn.net> wrote in message > news:C29193...

progress bar in dialog app
Hi: I have a dialog based application - which does a lot of number crunching and launches the dialog.(launching time is around a minute). The number crunching is done before the dialog even shows up on the screen. I dont have a splash screen currently to engage the user. I have decided to have a progress bar to display the status of completion - just for launching time. I didnt want to create a status bar and place the progress control there because the dialog itself shows only after a minute. So, I plan to have another dialog which holds the progress control, displays the status and quit...

Using CDC::DrawFrameControl() to add resize grip to dialog.
Hello, I am using CDC::DrawFrameControl()to add a resize grip to bottom right corner of my dialog. Everything works fine until I change the background color of the dialog to red using CDialog::OnCtlColor(). The color of the gripper doesn't change to red. Please help. Regards, Rafeeq CE My research thus far seems to imply that you wont be able to change it scolour using this technique. Regards Andy Mortimer [MS] Please do not send email directly to this alias. This alias is for newsgroup purposes only This posting is provided "AS IS" with no warranties, and confers no righ...

Import excel but selected column for selected table
I want to import excel to access but I want selected column to appear in selected table. For example i want to be able to specify column 1,2,3 to load in table 1 and column 4,5,8 to appear in table 2.. May i know the way please? -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200705/1 May I know the way please? Trever B wrote: >Suggestion, > >Import to a temp table > >Run 2 append queries appending the data to the files you want > >Trev > >> I want to import excel to access but I want selected column to ...