Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jan 2006
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Where condition (Access 2000)

    I have a problem with the Where condition to adjust in the select case statement to open a report.My problem, shown below is in case 3.it does not fit with the last command to open the report.How can I change the last command so as to accept also my case number 3 ?
    Private Sub Gains_Click()
    Dim stDocName As String
    Select Case Me!Gain
    Case 1
    stDocName = "RptGainMonths"
    Case 2
    stDocName = "RptGainSummary"
    Case 3
    Dim varInvoiceNumber As Variant
    varInvoiceNumber = InputBox("Please select document")
    If IsNumeric(varInvoiceNumber) Then
    DoCmd.OpenReport "rptGain", acViewPreview, , "[PaymentID] = " & varInvoiceNumber
    End If
    Case 4
    stDocName = "RptGain"
    End Select
    DoCmd.OpenReport stDocName, acPreview
    Clear
    End Sub

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

    Re: Where condition (Access 2000)

    You could specify only the ReportName and the WhereCondition in the Case 3 part:

    Private Sub Gains_Click()
    Dim stDocName As String
    Din stLinkCriteria As String
    Dim varInvoiceNumber As Variant

    Select Case Me!Gain
    Case 1
    stDocName = "RptGainMonths"
    Case 2
    stDocName = "RptGainSummary"
    Case 3
    varInvoiceNumber = InputBox("Please select document")
    If IsNumeric(varInvoiceNumber) Then
    ' Valid input
    strDocName = "rptGain"
    stLinkCriteria = "[PaymentID] = " & varInvoiceNumber
    Else
    ' Invalid input, so get out
    Exit Sub
    End If
    Case 4
    stDocName = "RptGain"
    End Select

    DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria
    Clear ' what is this?
    End Sub

  3. #3
    Lounger
    Join Date
    Jan 2006
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Where condition (Access 2000)

    Thank you, it runs inded !

Posting Permissions

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