Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to clear the conditions (Access 2000)

    On my form i have a combo box called CboEmployees and a command button with the following code :

    Dim strDocName As String
    Dim strwhere As String
    strDocName = "RptBonus"
    If Not IsNull(CboEmployees) Then
    strwhere = "[employeeid]=" & Me!CboEmployees
    End If
    DoCmd.OpenReport strDocName, acPreview, , strwhere
    Me![CboEmployees].Value = 0


    If i do not choose from the combo box, then the report opens for the all customers. If i choose an employee then i open only for this employee.
    However, in this case, if i try next to open the report for all the employees i receive an error. I have to close the form and open again, and then i can open the report
    for all the employees. How can i clear my conditions, so that if i choose to look for all the employess after
    i have looked for a given empployee, i can do that without reopening the form ?

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: How to clear the conditions (Access 2000)

    Why don't you change:

    If Not IsNull(CboEmployees) Then
    strwhere = "[employeeid]=" & Me!CboEmployees
    End If
    DoCmd.OpenReport strDocName, acPreview, , strwhere

    to:

    If Not IsNull(CboEmployees) Then
    strwhere = "[employeeid]=" & Me!CboEmployees
    DoCmd.OpenReport strDocName, acPreview, , strwhere
    Else
    DoCmd.OpenReport strDocName, acPreview
    End If

    Or you could just set strWhere = "" at the start of your code.

Posting Permissions

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