How to Autofill Textboxes on a Form using a Loop?

前端 未结 1 1170
时光取名叫无心
时光取名叫无心 2021-01-16 07:16

So I have a table that has a list of totals im trying to display on a form, I have 10 totals I need to get from the totals table and display in 10 textboxes on the form.

相关标签:
1条回答
  • 2021-01-16 07:53

    You cannot access an object reference directly using a concatenated string, as such reference is not of string data type.

    Instead, you will need to access the object from the relevant collection (in this case, the Controls collection), by supplying the name of the object (as a string) to the Item method of that collection.

    Since the Item method is the default method for a collection, the item name can immediately follow the collection as an argument.

    For example:

    For X1 = 1 To 10
        Me.Controls(TEXTX & X1).Value = DLookup(GETFIELDx, TABLENAMEx, FINDFIELDx & X1)
    Next X1
    
    0 讨论(0)
提交回复
热议问题