Concat ComboBox 选择到文本框 [英] Concat ComboBox choices into textbox

查看:42
本文介绍了Concat ComboBox 选择到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 3 张桌子:

  1. tbl1艺术家:ID - (PK),艺术家姓名,艺术家SKU
  2. tbl1中:ID - (PK),中型,中等SKU
  3. tbl1图稿:ID - (PK),Artist_ID - (FK),Medium_ID - (FK),件名,完成日期,艺术品SKU,缩略图

我想创建一个表单,其中有一个用于选择艺术家的组合框和一个用于选择媒体类型的单独组合框.将有一个用于输入作品名称的文本框和一个日期选择器(组合框).我需要将基于艺术家选择的 ArtistSKU 与基于 Medium ComboBox 选择的 MediumSKU 以及 TextBox 中 PieceName 的前 5 个字母连接起来.

I want to create a form that has a ComboBox for choosing an Artist and a separate ComboBox for choosing the medium type. There will be a TextBox for inputting the name of the piece and a date picker (ComboBox). I need to concatenate the ArtistSKU based on the choice from the Artist with the MediumSKU based on the choice from the Medium ComboBox, and the first 5 letters of the PieceName from the TextBox.

我做了一些研究,试图找出如何实现这一点,但没有运气.这可以通过查询在 Access 内部实现还是需要 VBA 才能实现预期结果?

I have done some research to try and figure out how to achieve this but with no luck. Can this be achieved inside of Access with queries or is VBA required to achieve the intended outcome?

我对 Access 不太熟悉,感谢所有帮助和指导.

I am not that familiar with Access and appreciate all the assistance and guidance.

如果您需要有关此请求的更多信息,请告诉我.

Let me know if you need further information about this request.

推荐答案

这可以通过查询或文本框中的表达式来完成.使用 Left() 函数提取前 5 个字符.

This can be accomplished with expression in query or textbox. Use Left() function to extract first 5 characters.

文本框中的示例:
=[cbxArtist] &[cbxMedium] &左([tbxPiece],5)

如果您想要的值实际上在组合框列表的另一列中,请通过其索引引用该列.索引从 0 开始.
<代码>=[cbxArtist] &[cbxMedium].Column(1) &左([tbxPiece],5)

If the value you want is actually in another column of combobox list, reference that column by its index. Index begins with 0.
=[cbxArtist] & [cbxMedium].Column(1) & Left([tbxPiece],5)

如果要将计算值保存到表中,则需要代码(宏或 VBA),但是,建议不要保存.保存的计算值可能与原始数据不同步".这个值可以在需要时计算.但如果你必须,那么代码应该是:
Me!ArtWorkSKU = Me.tbxArt
真正的诀窍是弄清楚要将这段代码放入哪个事件.试试表单 BeforeUpdate 事件.

If you want to save calculated value to table, that would require code (macro or VBA), however, advise not to save. Saved calculated values can become 'out of sync' with raw data. This value can be calculated when needed. But if you must, then code would be like:
Me!ArtWorkSKU = Me.tbxArt
The real trick is figuring out what event to put this code into. Try the form BeforeUpdate event.

这篇关于Concat ComboBox 选择到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆