Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2009
    Posts
    3

    Cool Unanswered: Ms Access Database

    I'm looking to create a query that can pull just the printer name.

    Document 254, Microsoft Office Outlook - Memo Style owned by abc6 was printed on AL-155-HPCFLJ via port AL-155-HPCFLJ. Size in bytes: 191373; pages printed: 2

    Can you please provide an example on how to select just the printer name?

    Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    well first off I'd try asking this questionm in the MS Access forum
    assuming the verbiage is the same ie ".... was printed on <blah di blah printer via......." then you coudl write a VB function which returned the printer name

    eg
    Code:
    function GetPrinterName (aString as string) as string
    GetPrinterName="" 'set up our default return parameter
    dim StartAt as inetger
    dim EndAt as integer
    StartAt= instr(aString, "printed on ")
    if startat>0 then 
      endat = instr(aString, " via port")
      if endat>0 then 'extract the printer name fromt he text ' note the popinters/indexes may need adjusting
        GetPrinterName = mid(aString,startat+12, len(astring)- startat+12)
      else   'we didn't find the port name so lets just presume the rest of the text has been cropped
        'of course you could decide that the port had been dropped and you still need to chop the ...size
    'so theres nowt stopping you addign the code to chop that if you so need
        GetPrinterName = mid(aString,startat+12)
      endif
    else 'we didn't find the printer name
      GetPrinterName = "Cannot find details of Printer"
    endif
    end function
    100&#37; aircode, not coded, tested or whatever. like all things free its valueless unless you make the appropriate moves
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2009
    Posts
    3
    Thanks for replying so promptly, I forgot to include an important detail. The column name is "Message".

    Does it has any effect on the vb script you posted before?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    no becuase you pass that to the function as the parameter

    eg
    MyPrinterName = GetPrinterName([Message])
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Dec 2009
    Posts
    3
    Ok, I went to Microsoft Visual Basic, in access, created a new module, insert your code, ran a test. Nothing was coming back. Basically, it was a silent moment.

    Then, I went back to Microsoft Visual Basic, click on debug, compile debug, an error came up "Compile error: User-defined type not defined.

    I'm sure there is a step missing on my part here.....

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I did tell you it was air code, ie untested

    so where did the code stop at
    what do you think the error message is trying to tell you.

    what steps have you taken to try and work out where the code failed. do you know which line the code failed on
    assuming you have taken such steps what do you think you need to do to fix the problem

    fwiw there is a simple typo that I can see immediately
    there may be more errors I dunno, as its air code.. its not tested.

    I suggest you follow the debugging process.. look for where the code halts
    its no bad thing when installing someone elses code to put a break point on it to find out whatr is going on. indeed you may need to to make certain the instr parameters are correctly defined
    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
  •