Results 1 to 4 of 4
  1. #1
    Join Date
    May 2007
    Posts
    3

    Unanswered: How to eliminate invalid bracketing of name

    Hi all,

    i am new to VB. when i was tested one report. I got one error that is: Run time error '3126': Invalid bracketing of name '[Forms!Main!FromDate]'.

    Code:

    FileOut = FixName("EMPerformance-" & Format(Forms!Main!FromDate.Value, "mmddyy") & "-" & Format(Forms!Main!ToDate.Value, "mmddyy") & ".xls")
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "EMPerformance", TempLoc & FileOut, True, "Summary"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "EMPerformanceBase", TempLoc & FileOut, True, "EM Scheduled Detail"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "EMPerformanceBase-Completed", TempLoc & FileOut, True, "EM Completed Detail"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "EMPerformanceBase2-NewSR", TempLoc & FileOut, True, "EM New Detail"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "EMPerformanceBase3-Pending", TempLoc & FileOut, True, "EM Pending Detail"


    Anyone can help me it would be very useful to me.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Forms!Main.FromDate.Value ?
    George
    Home | Blog

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Or
    Forms("Main").FormDate.value
    Or
    Forms("Main").FormDate

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if you are calling this piece of code from within form main then Id suggest cuttign the crud and using...
    FileOut = FixName("EMPerformance-" & Format(FromDate, "mmddyy") & "-" & Format(Forms!Main!ToDate.Value, "mmddyy") & ".xls")

    alternatively you could use a method call in main eg

    public function GetFromDate(optional style as byte = 0) as string
    dim DateValue as date, strformatMask as string
    'style could be a differnet method of returning the date
    'eg 0= yyyymmdd, 1 = dd mmm yyyy, 2 = dd mm yyyy, n= xxxxxxxx
    if not isnull(fromdate) and isdate(fromdate)
    DateValue=cdate(FromDate)
    else
    'some form of error trap or default
    DateValue=now()
    endif
    select case style
    case 0: strformatMask = "YYYYMMDD"
    case 1: strformatMask = "dd mmm YYYY"
    case 0: strformatMask = "dd mm yyyy"
    case n: strformatMask = "xxxxxxxxxxx"
    case else strformatMask = "YYYYMMDD"
    end select
    GetFromDate= format (DateValue, strfomramtmask)
    end function

    and then call it...


    incidentally if you are outputting this to an excel file I'd recommend that you output the date as YYYYMMDD.. that way round the filenames will be in ascending order.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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