首页 > 解决方案 > MS Access VBA - Runtime Error 438 when setting ControlSource-Property in Form

问题描述

After years of MS-Access abstinence, I decided to help a friend manage guesthouse bookings by writing a database for him.

To display bookings, I am building a form frmHello like this:

        Mon, Dec 2   Tue, Dec 3   Wed, Dec 4
--------------------------------------------
room 1  [Smith   ]   [Smith   ]   [Smith   ]  
--------------------------------------------
room 2  [        ]   [        ]   [Miller  ]  
--------------------------------------------
room 3  [        ]   [Adams   ]   [        ]

[xxx ] are unbound textboxes. frmHello is unbound, on_load I call Sub Init() to organize the data in a (temporary) table tblHello, then bind frmHello to tblHello and bind the textboxes to their specific fields in tblHello in Sub bind().

And this is where the mess started: Microsoft Visual Basic keeps reporting a runtime-error 438: object doesn't support property or method and marks line 5 below:

1    Private Sub bind()
2      Me.Recordsource = "tblHello"
3      For n = 0 to 3
4        Me("txtBooking" & n).ControlSource = "helloBooking" & n
5        Me("txtStatus" & n).ControlSource  = "helloStatus" & n  <------- marked line
6      Next
       ...

Note that line 4 runs perfectly...

What I've tried:

---> same error :-(

Who can help, please?

I'm running Access 2019 64bit on Win 10.

标签: vbams-access

解决方案


推荐阅读