在此Access数据库模式中是否有一种简单的填充下拉列表的方法? [英] Is there a simple way of populating dropdown in this Access Database schema?

查看:1073
本文介绍了在此Access数据库模式中是否有一种简单的填充下拉列表的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3张表,如下所示:

 位置节点Sektor 
----- - ----- -------
PK:ID - 自动编号PK:ID - 自动编号PK:ID - 自动编号
名称NodeName Sektor
高度Aksess频率
纬度标签覆盖
长度IP

每个位置都与多个连接多个节点的节点连接。



现在有趣的部分。在Microsoft Access中,您可以制作允许用户轻松添加数据的模式。我有最终的表格,我想使用我的模式来插入数据:

 客户
- ------
PK:CustID
名称
订阅
Sektor

这是我想要完成魔法的地方。我希望用户能够首先选择一个位置,然后显示可用的节点(最好在下拉列表中),最后他可以为他添加的客户选择正确的sektor。



任何人都知道一个相当简单的方法吗?我开始为此做一个宏,但是我对宏的记忆是非常糟糕的atm,我没有正确的文学与我atm来查找。



任何帮助appriciated =)

解决方案

确实命名任何名称是一个非常糟糕的主意。



在我看来,你需要级联组合框。您将需要一个VBA。



两个组合框称为cboLocation和cboNodes,在一个forrm中称为frmForm



cboLocation

  RowSource:SELECT ID,[Name] 
FROM位置
ORDER BY [Name]

ColumnCount:2

ColumnWidths:0; 2.00cm第二列可以是任何合适的宽度

LimitToList:是

事件:

 code> Private Sub cboLocation_AfterUpdate()
Me.cboNode.Requery
End Sub

CboNode

  RowSource:SELECT ID,NodeName 
FROM节点
WHERE IP = [表单]![frmForm]![cboLocation]
ORDER BY NodeName

ColumnCount:2

ColumnWidths:0; 2.00''同上

LimitToList:是

事件:

  Private Sub cboNode_GotFocus()
如果Trim(Me.cboLocation&)= vbNullString Then
MsgBox请选择位置
Me.cboLOcation.SetFocus
End If
End Sub

您还需要一个表单事件:

  Private Sub Form_Current()
Me.cboNode .Requery
End Sub


I have 3 tables which look like this:

Location                Node                 Sektor
-----                   -------              -------
PK: ID - Autonumber     PK: ID - Autonumber  PK: ID - Autonumber
Name                    NodeName             Sektor
Height                  Aksess               Frequency
Latitude                Tag                  Coverage
Longtitude              IP

Each location is connected with multiple nodes which is connected with multiple sektors.

Now the interesting part. In Microsoft Access you can make schemas which allows users to easily add data. I have the final table looking like this which I want to use my schema to insert data into:

Customers
-------
PK: CustID
Name
Subscribtion
Sektor

This is where I want the magic to be done. I want the user to be able to first select a location, then be presented with available nodes (preferably in dropdown) and finally he can pick the correct sektor for the customer hes adding.

Anyone know a fairly easy way of doing this? I started making a macro for this, but my memory of macros are really bad atm, and I dont have the correct literature with me atm to look it up.

Any help appriciated =)

解决方案

It is a very bad idea indeed to name anything Name.

It seems to me that you need cascading comboboxes. You will need a little VBA.

Two combo boxes called, say, cboLocation and cboNodes, on a forrm called, say, frmForm

cboLocation

RowSource: SELECT ID, [Name]
FROM Locations
ORDER BY [Name]

ColumnCount: 2

ColumnWidths: 0;2.00cm  ''The second column can be any suitable width

LimitToList: Yes

Events:

Private Sub cboLocation_AfterUpdate()
    Me.cboNode.Requery
End Sub

CboNode

RowSource: SELECT ID, NodeName
FROM Nodes
WHERE IP=[Forms]![frmForm]![cboLocation]
ORDER BY NodeName

ColumnCount: 2

ColumnWidths: 0;2.00 ''Ditto

LimitToList: Yes

Events:

Private Sub cboNode_GotFocus()
    If Trim(Me.cboLocation & "") = vbNullString Then
        MsgBox "Please select location"
        Me.cboLOcation.SetFocus
    End If
End Sub

You will also need a form event:

Private Sub Form_Current()
    Me.cboNode.Requery
End Sub

这篇关于在此Access数据库模式中是否有一种简单的填充下拉列表的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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