Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where to condition (Access 2000)

    How can i open a report with two where conditions? In my from i can open the report with one condition as follows:
    DoCmd.OpenReport ReportName:="rptClientActions", _
    View:=acPreview, WhereCondition:="ClientID = " & Forms!frmClients![Clientid]
    However in my subform i have several memos and i want the report to open only for my last memo and not al the memos in a given client.How can i open the report for aq given client and only with the last memo in it ?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Where to condition (Access 2000)

    Here is some code:

    Dim lngClientActionID As Long
    Dim stDocName As String
    Dim strCriteria As String
    strCriteria = "([clientID] =" & Me![ClientID] & ")"
    lngClientActionID = Nz(DMax("[ClientActionID]", "tblclientActions", strCriteria), 0)
    If lngClientActionID > 0 Then
    strCriteria = strCriteria & " and ( [ClientActionID]=" & lngClientActionID & ")"
    stDocName = "rptClientActions"
    DoCmd.OpenReport stDocName, acPreview, , strCriteria
    Else
    MsgBox "There are no actions for this client", vbInformation

    End If

    You want the last action. Does this mean the last one created, or the one with the latest date? They may be the same. My code just finds the last one created, because it will have the largest ClientActionID for that client.
    Regards
    John



  3. #3
    2 Star Lounger
    Join Date
    Aug 2005
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Where to condition (Access 2000)

    Thank you so much John.That is what i wanted.

Posting Permissions

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