从组合框中保存用户选择 [英] Save user selection from combo boxes

查看:61
本文介绍了从组合框中保存用户选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经离开编程大约10年了,我正在Access 2010中为自然中心做一个小型志愿者项目。


我有一个表格从查询中填充2个组合框... 1具有"参与者"和"参与者"。 (姓名和ID)和另一个 具有"事件"和"事件"。 (姓名和ID)。 我有一个目的地表有4列(ID(自动),参与者ID(数字),事件ID(数字)
和DateAdded(现在()))。


我想要从每个组合框数据中获取ID值并向我的"ParticipantToEvent"添加新行。表。


最便捷的方法是什么?


注意:


我已经使用了尽可能多的绑定控件,因为这个应用程序将在我离开后很长时间内存活,并且需要尽可能简单地保留以供将来维护。



提前感谢您的帮助。


Phill






SquireDude

解决方案

嗨Phil,


最方便的方法是绑定组合框;但如果您使用未绑定的组合框,则可能需要使用APPEND查询将选择推送到表中。例如:


strSQL =" INSERT INTO ParticipantToEvent(ParticipantID,EventID)VALUES(& Me.Combo1&",& Me.Combo2&" ;)"


CurrentDb.Execute strSQL,dbFailOnError


请注意,上面假设DateAdded的默认值设置为Now()。


希望它有所帮助...



I've been away from programming for about 10 years and I'm doing a small volunteer project in Access 2010 for a Nature Center.

I have a form with 2 combo boxes populated from queries... 1 has "Participant" (Name & ID) and the other has "Event" (Name & ID).  I have a destination table with 4 columns (ID(Auto), ParticipantID(Number), EventID(Number) and DateAdded(Now())).

I would like to take the ID values from each combo boxes data and add a new row to my "ParticipantToEvent" table.

What is the most expedient method to do this?

NOTE:

I have used as many bound controls as possible as this app will live long after I have left and needs to stay as simple as possible for future people to maintain.

Thanks in advance for your kind help.

Phill


SquireDude

解决方案

Hi Phil,

The most expedient method would be to bind the comboboxes; but if you're using unbound comboboxes, then you may need to use an APPEND query to push the selections to the table. For example:

strSQL = "INSERT INTO ParticipantToEvent (ParticipantID, EventID) VALUES (" & Me.Combo1 & "," & Me.Combo2 & ")"

CurrentDb.Execute strSQL, dbFailOnError

Please note the above assumes DateAdded has a Default Value set to Now().

Hope it helps...


这篇关于从组合框中保存用户选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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