The access report will not allow me to refer to a field in VBA if it is not specified in the report myself

So, in the access form or in the report, it’s good to demonstrate something dynamic on the screen, which is more difficult than =[UnitPrice]*[Quantity]it is to go to VBA.

eg. in this simplified example, the base table for this report has two fields: ShowTax and TaxRate . Having created the TextBox control source =GetTaxInfo, I will get some complexity in VBA:

Public Function GetTaxInfo() As String

    Dim result As String
    If Me!ShowTax = 0 Then
        result = "Tax included @ " & Me!TaxRate

    Else
        result = ""
    End If

    GetTaxInfo = result

End Function

, ... - , TaxRate. #Error. , VBA. , , , .

, VBA, , , ?

, . ? ( /, / reimport ..)

Edit:

... . - , . , .

+3
1

/.

, RecordSource ( ). , .

Public Function GetTaxInfo(ShowTax as Boolean, TaxRate as Single) As String 

    Dim result As String 
    If ShowTax = 0 Then 
        result = "Tax included @ " & TaxRate 

    Else 
        result = "" 
    End If 

    GetTaxInfo = result 

End Function 

.

+4

Source: https://habr.com/ru/post/1769785/


All Articles