如何动态设置所有申请表标题属性
我有一个 Access 应用程序,可以访问 3 个环境(DEV;TEST;PROD)。登录时设置环境变量,以便以编程方式连接到正确的数据库。
我们希望用户能够看到他们使用的每种形式连接到哪个环境。一种想法是设置标题栏的颜色,但这会影响所有窗口。
我一直在尝试使用环境变量将环境动态地放入表单标题中。
在表单属性中设置事件过程,例如“当前”或“打开”,例如:
Me.Caption = Me.Caption & ” : “ & Me!txtEnvName.Value
.... 在登录应用程序时的动态过程中是我想做的。
手动更改应用程序中的所有表单并不是理想的选择。
以下是表单在 3 种不同环境中的外观示例:
Customers: DEV
//////////
Customers: TEST
/////////
Customers: PRODUCTION
I have one Access application which accesses 3 environments (DEV; TEST; PROD). An environment variable is set upon login to programmatically connect to the correct database.
We would like the user to see which environment they are connected to in each form they use. One thought is to set the color of the title bar, but that impacts all windows.
I have been attempting to put the environment in the form caption dynamically by using the environment variable.
Setting an Event Procedure in the Form Properties such as On Current or On Open such as:
Me.Caption = Me.Caption & " : " & Me!txtEnvName.Value
.... in a dynamic process upon signin to the application is what I would like to do.
Manually changing all the forms in the application is not a desired option.
Here is a sample of what a form would look like in the 3 different evironments:
Customers: DEV
//////////
Customers: TEST
/////////
Customers: PRODUCTION
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以轻松地为所有表单设置标题:
但是,我建议您使用每个表单的 Open 事件来检查全局变量并相应地设置标题。
You can set the captions for all the forms easily enough:
However, I suggest you use the Open event of each of the forms to check a global variable and set the caption accordingly.
这会将 COMPUTERNAME 环境变量添加到我的表单的标题中。
如果您还想使用颜色来区分数据库实例,则可以更改详细信息部分的背景颜色。这将根据 Your_env_variable 的值更改它。
This adds the COMPUTERNAME environment variable to the Caption of my form.
If you want to also include color to distinguish between the database instances, you could change the detail section background color. This would change it based on the value of Your_env_variable.