Results 1 to 8 of 8
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    I used the following code in the past to email the current record, but now I get an error message that it no longer recognizes the WhereCondition. Any Suggestions?

    Private Sub cmdEmailReport_Click()
    On Error GoTo Err_cmdEmailReport_Click

    If Me.Dirty Then
    DoCmd.Requery
    End If
    stDocName = "rptOneShutinWithVisit"
    DoCmd.SendObject acReport, stDocName, "SnapshotFormat(*.snp)" WhereCondition: ="[tblShutins.ID]=" & Me.[tblShutins.ID]


    Exit_cmdEmailReport_Click:
    Exit Sub

    Err_cmdEmailReport_Click:
    MsgBox Err.Description
    Resume Exit_cmdEmailReport_Click

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='Chuck Tucker' post='764687' date='10-Mar-2009 21:30'][/quote]
    WhereCondition can be used with DoCmd.OpenForm and with DoCmd.OpenReport, but not with DoCmd.SendObject.
    A workaround is to set the record source of the report to a query that refers to the ID field on the form in the Criteria for the ID column.

  3. #3
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    Thanks Hans. I'll go to work on it.

  4. #4
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    I have set up a query, but I'm perplexed as to how to set the criteria such that it selects only the current record from the form from which the query gets called. Any suggestions?

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Chuck Tucker' post='765117' date='12-Mar-2009 19:47'][/quote]
    You need your field [tblShutins.ID].
    If it isn't then add it to the query that is the recordsource of the report.
    In the criteria from the column [tblShutins.ID] enter something like [forms]![YourFormName]![tblShutins.ID].
    You can now run the report when the form is open and you'll have only one record
    Francois

  6. #6
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post
    I modified the query (I tried to attache an example, but with this new format I don't know if it comes through). However, when I run the report based on the query I get an "Invalid bracketing of name" error message.

    The criteria statement is: [forms]![frmShutinWithVisits]![tblShutins.ID]

    Am I missing something here?

    [attachment=82825:query.jpg]

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

    [Forms]![frmShutinWithVisits]![NameOfTheControl]

    where NameOfTheControl is the name of the control bound to tblShutins.ID.

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Chuck Tucker' post='765143' date='12-Mar-2009 22:06'][/quote]
    On the form, rename [tblShutins.ID] textbox to ID
    And in the criteria use [forms]![frmShutinWithVisits]![ID]
    The query seems to not like the period in the name of the control
    Francois

Posting Permissions

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