Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Coding question (2003)

    Hi,
    I have this bit of code:

    Private Sub cmdExport_Click()

    'The path below needs to be altered to where the excel document is kept

    Const strExcelFile = "P:TRIALS UNITWAVESWAVESdatabase1812.xlt"

    What I'd like to do is to set up a table, and from this a form, where the user can enter the path of an excel template and have it replace the path above.
    Not too sure what to do with the coding. The table would be called TblExcelPath and would only have one record (presumably).

    Any help would be appreciated!

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

    Re: Coding question (2003)

    Say you have a table TblExcelPath with one field ExcelPath of type Text. The table contains one record. You can use DLookup to retrieve the value:

    Dim strExcelFile As String
    strExcelFile = DLookup("ExcelPath", "TblExcelPath")

  3. #3
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Coding question (2003)

    Just before I impliment this, I'm hoping that it will wotk in the context of the rest of the coding:

    Private Sub cmdExport_Click()

    'The path below needs to be altered to where the excel document is kept

    Const strExcelFile = "P:TRIALS UNITWAVESWAVESdatabase1812.xlt"

    Dim strSQL As String
    Dim cnn As ADODB.Connection
    Dim rst As New ADODB.Recordset
    Dim xlApp As Excel.Application
    Dim xlWbk As Excel.Workbook
    Dim xlSht As Excel.Worksheet
    Dim blnStartExcel As Boolean
    Dim lngRow As Long
    Dim lngRows As Long

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

    Re: Coding question (2003)

    The code should work OK.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2004
    Location
    Norfolk, England
    Posts
    744
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Coding question (2003)

    Thanks Hans!

Posting Permissions

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