Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47

    Unanswered: Export without knowing file locations

    I am trying to write the code to export a query. The database will be a runtime version that will be installed by the owners not by me so I will not know where the database is located or where to file is being exported to. Basicly I want to say, "Okay transfer this query from this database where ever it has been saved to a file named Quilts that can be saved anywhere you want it to be saved." Ideally, I would love to be able to pull up the Save dialog boxes to allow people to chose their own location for the save whether it be the A: or the desktop or where ever. I have no guarrentee that people will even have office to chose the My Documents and they could be using any version Windows, so it is even impossible to write the path for the desktop.

    While I am at it, I then also need to be able to have others import that file into their version of the database.

    Thank you.

    Terri Gavin

  2. #2
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    574
    In Access97, I let the user browse for the file by creating a form called _OpenDialog with an activeX control with the class of
    MSComDlg.CommonDialog.1

    In the code, I have:

    Private Sub Form_Open(Cancel As Integer)
    Dim getfile As String
    Dim activefile As String
    Dim Message As String
    Dim st1 As String, frm As Form
    Dim Current
    Dim Yr
    If Nz(Me.OpenArgs, "Voters") = "Sup" Then
    st1 = "All Files (*.*)|*.*|Supp Omit Files|*.sup"
    Set frm = Forms!ImportSupData
    Else
    st1 = "All Files (*.*)|*.*|Voter Notification Files|*.vnf"
    Set frm = Forms!ImportSupData
    End If
    Current = DLookup("[Value]", "UserSettings", "[Code] = 'CurrentDatabaseFile' ")

    On Error Resume Next
    Begin:
    CommonDialog1.CancelError = True
    On Error GoTo ErrHandler
    CommonDialog1.flags = 8198 'cdlOFNCreatePrompt + cdlOFNOverwritePrompt + cdlOFNHideReadOnly
    CommonDialog1.Filter = st1
    CommonDialog1.FilterIndex = 2
    CommonDialog1.InitDir = left(Current, InStr(Current, "Quilt.md") - 7)
    CommonDialog1.DialogTitle = "Open Import File"
    CommonDialog1.ShowOpen
    getfile = CommonDialog1.FileName
    CommonDialog1.FileName = ""
    frm!FName = getfile
    DoCmd.Close acForm, "_OpenDialog"

    Exit Sub

    ErrHandler:
    getfile = ""
    DoCmd.Close acForm, "_OpenDialog"
    End Sub

    Add to this my code for relinking:
    http://www.dbforums.com/t972590.html and you can open any database that has the right backend tables.

Posting Permissions

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