Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Feb 2006
    Thanked 0 Times in 0 Posts

    auto fill criteria for query (2003)

    User completes a form and 'after update' of SERIAL field kicks off code to auto-print a label of data just entered using query criteria (like[ ]) based report.
    If using code below and set to acPREVIEW, record is found and preview occurs. If set to acPRINT, code "misses"
    sendkey commands and criteria/parameter window is displayed waiting for user input. Is there another way to force
    "myvalue" into criteria?
    myvalue = Serial
    stDocName = "Report-printed"
    SendKeys myvalue
    SendKeys "{enter}"
    DoCmd.OpenReport stDocName, acPrint Ďauto print report for Serial# from previous record
    DoCmd.GoToRecord , "", acNewRec
    Forms!tbl_scanned!IN.SetFocus 'setup new record input

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: auto fill criteria for query (2003)

    One option is to refer to the form in the criteria in the query: instead of using something similar to
    Like [Enter Value Here]
    Like [Forms]![NameOfTheForm]![Serial]
    Another option is to remove the condition from the query, and pass it to the report in the WhereCondition argument of DoCmd.OpenReport:
    stDocName = "Report-printed"
    DoCmd.OpenReport ReportName:=stDocName, WhereCondition:="[NameOfTheField] Like '" & Me.Serial & "'"
    Substitute the relevant name.

Posting Permissions

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