获取ID从组合框提交一个文本框,其中第一列设置为0 [英] Get ID Filed from a Combobox in a Text Box where 1st column set to 0

查看:141
本文介绍了获取ID从组合框提交一个文本框,其中第一列设置为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,在这里我想实现级联组合框。

I have a form, where I want to implement cascading combo-box.

第一用户选择客户端名称在那里我有SQL语句得到3列 - 客户端ID,客户名和客户端姓氏。为了让用户输入名字,而不是ID,已设置了列宽:0; 3

1st user selects "Client Name" where I have SQL statement getting 3 columns - CLient ID, Client First Name and Client Last Name. In order to allow users to enter First Name, instead of ID, have set the Column Width: 0;3

第二个则用户选择工作在那里我有SQL语句得到2列 - 工作证,工作描述。为了让代替ID用户输入工作说明,已经设置了列宽:0; 2

2nd then user selects "Work" where I have SQL statement getting 2 columns - Work ID, Work description. In order to allow users to enter Work description, instead of ID, have set the Column Width : 0;2

要级联列表,所以在组合框中的工作清单只显示 工作表有一个外键,客户端ID。

Want to cascade the list, so that "Work" list in combo-box only shows the Work table has a foreign key to Client ID.

我通过增加SQL语句行来源的工作组合框实施层叠组合框。

I implemented the cascading combo-box by adding SQL Statement to Row Source of work Combo-box.

SELECT WorkTbl.WorkID, WorkTbl.WorkDescription, WorkTbl.ClientID 
FROM WorkTbl 
WHERE (((WorkTbl.ClientID)=Forms![Work Done Entry]!cboClientID);

cboClientID是组合框的客户端的名称。

"cboClientID" is name of the Combo-box of Client.

不过,因为用户将进入,而不是客户端ID,因为已经设置了列宽客户端名称:0; 3 上cboClientID。 因此,SQL查询是行不通的。

But since the User will be entering in "Client Name" instead of "Client ID" because of have set the Column Width: 0;3 on cboClientID. Hence the SQL Query is not working.

有没有变通? 一个解决方案,我发现(但不能使它工作)是添加一个文本框并设置客户端ID在该文本框,然后让我们这个文本框来获得在SQL所需的客户端ID。 有这个想法的形式该课题

Is there any work around? One solution, which i found (But could not make it work) was to add a Text-box and set Client ID in this Text-Box and then make us of this Text box to get the client ID required in the SQL. Got this idea form This Question

先谢谢您的回答这个问题。 任何帮助或建议AP preciated。

Thanks in advance for answering this Question. Any help or suggestion appreciated.

推荐答案

你怎么样用你的CboclientID组合框的关于更新后,事件?

How about you use the "on after update" event of your "CboclientID" combobox?

只是添加此code到你的cboClientID组合框的更新事件后:

just add this code to your "cboClientID" combobox on after update event:

Dim SQL_GET As String
SQL_GET = "SELECT WorkTbl.WorkID, WorkTbl.WorkDescription From WorkTbl WHERE (((WorkTbl.ClientID)=" & Nz(Me.cboClientID.Value, 0) & ");"
Me.cboWork.RowSource = SQL_GET

这样每次当你更新你的客户端名称您的工作组合框也会根据您的选择改变的时间。 希望这有助于。

this way every time when you update your client name your work combobox will also change according to your selection. hope this helps.

这篇关于获取ID从组合框提交一个文本框,其中第一列设置为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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