Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    code for record source (Access 2000)

    In the OnOpen event of the report i have a string strSize which i define each time for each report
    for example:
    Select Case Forms![Form1]![Pack]
    Case 1
    strSize = "And ((products.size) < 6)"
    Case 2
    strSize = "And ((products.size) = 205)"
    Case 3
    strSize = "And ((products.size) > 0.4)"
    End Select


    Reports(StrReportName).RecordSource = strBas & strSize

    I want to build a specilal global function to call every time i use the strSize.
    For example i tried to use a function

    Public Function GetSize() As String
    Dim strSize As String
    Select Case Forms![FBenchmark]![Gebinde]
    Case 1
    strSize = " And ((products.size) = <6)"
    Case 2
    strSize = " And ((products.size) =205)"
    Case 3
    strSize = " And ((products.size) = > 0.4)"
    End Select
    GetSize = strSize
    End Function

    But how can i replace it in the code?
    May be strSize = GetSize, but it fails
    So my question is how can i replace the StrSize with e globlal code and not to write it each time in the following line:

    Reports(StrReportName).RecordSource = strBas & strSize

    Thank you in advance

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: code for record source (Access 2000)

    Some possible errors:
    - in the sample you use Forms![Form1]![Pack] and in the routine Forms![FBenchmark]![Gebinde] ???
    - in the routine you use = < with a space and in the sample < only
    - make sure that in the final string the parentheses are in balans.
    To control this, use the following code in the on open event of the report
    Dim strSQL
    Dim strBas
    ' here code to make strBas
    strSQL = strBas & GetSize
    Me.RecordSource = strSQL
    You can put a breakpoint on the line me.recordsource and look in the immediate window what stsSQL contains.
    -You have to set the recordsource in the on open event of the report. You can't set it out the report.
    Hope this help
    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
  •