• code for record source (Access 2000)

    Author
    Topic
    #366799

    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) 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) = 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

    Viewing 0 reply threads
    Author
    Replies
    • #570065

      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

    Viewing 0 reply threads
    Reply To: code for record source (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: