vba - 如何使用 VBA 将文本框中输入的值分配给另一个表单 MS Access 上的组合框选择
问题描述
我有一个包含 6 个文本框的表格,其中 3 个保存月度、季度和年度会员类型的更新货币价值。In another form I have a combobox with the 3 types of membership, when a membership type is selected I want to output the updated monetary value of the selection to a textbox. 如果有人可以帮助/推荐任何足智多谋的链接,将不胜感激。我对 vba 的理解还不错,但是在编写正确运行的代码时遇到了困难。
Private Sub cbMmemberType_change()
If cbMemberType.Text = "Monthly" Then
frmSubscriptionDetails.txtSubCost.Text = frmUpdatedCosts.txtUpdatedMonth.Text
ElseIf cbMemberType.Text = "3 Months" Then
frmSubscriptionDetails.txtSubCost.Text = frmUpdatedCosts.txtUpdated3Months.Text
ElseIf cbMemberType.Text = "Annual" Then
frmSubscriptionDetails.txtSubCost.Text = frmUpdatedCosts.txtUpdatedAnnual.Text
End If
End Sub
解决方案
Text属性仅在控件具有焦点时有效,并使用AfterUpdate事件,因此请尝试:
Private Sub cbMmemberType_AfterUpdate()
Select Case Me!cbMemberType.Value
Case "Monthly"
frmSubscriptionDetails!txtSubCost.Value = frmUpdatedCosts!txtUpdatedMonth.Value
Case "3 Months"
frmSubscriptionDetails!txtSubCost.Value = frmUpdatedCosts!txtUpdated3Months.Value
Case "Annual" Then
frmSubscriptionDetails!txtSubCost.Value = frmUpdatedCosts!txtUpdatedAnnual.Value
End Select
End Sub
推荐阅读
- python - Python如何获取图像然后发布(通过请求库)
- java - 在 Java 中将列表列表转换为 HashTable
- weblogic11g - Weblogic 是否支持跨多个托管服务器的本地配置
- azure - 我可以提交一个天蓝色的日志查询来获取当前的日期时间吗?
- sql - SQL将日期“四舍五入”到一周中的给定日期
- ruby - 红宝石 1.8.7 RUBYOPT(运行时错误)
- woocommerce - 在 WooCommerce 产品页面中显示来自自定义 wp_editor 页面的内容
- java - Java:异步序列化对象到文件
- go - 如何在 Golang 中用不同的签名装饰函数?
- html - 尝试使用视口宽度设置 div 的宽度不起作用