从组合框中删除选择 [英] Deleting a selection from a combobox

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

问题描述




有任何1我可以看到以下的例子:




[PHP]一个删除按钮,用于删除在组合框中选择的项目[/ PHP]




i急需它? ???????


甚至任何代码!!!!



has any1 got any examples i can look at for the following:




[PHP]A delete button that deletes the item selected in the combobox [/PHP]




i need it urgently???????please

or even any code!!!!

推荐答案

假设组合框命名为 cmbX"有一个记录源,如:


选择代码,说明来自tblX


您可以使用以下代码编写按钮:
Assuming the combobox named "cmbX" has a recordsource like:

select code, description from tblX

You can code a button with:
展开 | 选择 | Wrap | 行号


我已经尝试过你的想法Nico ....


组合框称为 Combo2

Combo2的行源是:


[PHP] SELECT [tab_main]。[username] FROM tab_main ORDER BY [username]; [/ PHP]


用于删除按钮的代码是:


[PHP] Private Sub Command11_Click()

On Error GoTo Err_Comman d11_Click


如果Len(Nz(Me.Combo2))> 0然后


CurrentDb.Execute(" delete * from tab_main where code ="& Me.Combo2)

Me.Combo2.Requery

结束如果

Exit_Command11_Click:

退出子


Err_Command11_Click:

MsgBox Err.Description

恢复Exit_Command11_Click


结束子[/ PHP]


但我收到以下错误消息:

查询表达式中的语法错误(缺少运算符)''code = Adam Beaky''。


Adam Beaky是从组合框中选择的一个例子
ive tried your idea Nico....

the combobox is called Combo2
the row source of Combo2 is:

[PHP]SELECT [tab_main].[username] FROM tab_main ORDER BY [username];[/PHP]

the code im using for the delete button is:

[PHP]Private Sub Command11_Click()
On Error GoTo Err_Command11_Click

If Len(Nz(Me.Combo2)) > 0 Then

CurrentDb.Execute ("delete * from tab_main where code=" & Me.Combo2)
Me.Combo2.Requery
End If
Exit_Command11_Click:
Exit Sub

Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click

End Sub[/PHP]

but im getting the following error message:

Syntax error (missing operator) in query expression ''code=Adam Beaky''.

Adam Beaky is an example selected from combobox


嗯,我假设代码是数字的,因为嵌入单引号的字符串是强制性的,如:


" SELECT * FROM x WHERE code =''" &安培; me.combobox& "''")


或者当您使用嵌入式报价的名称时:


" SELECT * FROM x WHERE code = QUOT; &安培; chr(34)& me.combobox& chr(34))


Nic; o)
Hmm, I assumed the code was numeric, for a string embedding in single quotes is mandatory like:

"SELECT * FROM x WHERE code=''" & me.combobox & "''")

Or when you have names wih an embedded quote use:

"SELECT * FROM x WHERE code=" & chr(34) & me.combobox & chr(34))

Nic;o)


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

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