帮助基于多对多关系的表单 [英] Help with Forms based on Many to Many relationship

查看:84
本文介绍了帮助基于多对多关系的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。我不确定我们是否可以在这里发帖提问。很抱歉,如果这不是正确的地方。


我真的需要帮助。


我有一个包含表格和子表格的数据库绑定到多对多的关系。


如何导入excel文件并在相应的表中自动输入这些值?

解决方案

这不是启动技术线程的真正Hyperpau的地方,但你可以在我把它移到论坛之后发布另一个带有指针的线程如果你愿意的话。

我喜欢工作人员的想法。应该期待他们的同事提供最高水平的帮助。我现在订阅了,但现在已经很晚了,所以我明天再试一次。

在平均时间里,尝试用这个示例模板来解释你的数据结构对于表Meta-Data:
表名= tblStudent

展开 | 选择 | Wrap | 行号


Don不要打扰另一个(指针)线程。无论如何,当我移动线程时,我在那里留下了一个指针:)


事实上,我在过去已经做了几次这样做,唯一真正有用的是使用记录集。逻辑可能会有点复杂,但是一旦你完成它就是最简单的方法。


例如如果您正在处理两个表,那么您将打开一个记录集,如下所示:
  • Excel电子表格,导入到表或链接。
打开记录集的循环并读入第一条记录。


在适当的insert语句中使用docmd.runsql添加适合于table1的字段值。如果您的ID密钥是表上的自动编号,那么您必须以某种方式在插入记录后检索该值,可能在自动编号上使用DMax。


然后创建一个插入语句来添加您的数据到table2。假设ID又是一个自动编号,你可以像上面那样检索它。


最后你要创建一个insert语句来添加表1和2中两个主键的复合主键。 br />

这里的问题将解决如何在逻辑上管理所有三个以处理多对多关系的逻辑。


没有看到excel电子表格很难说你会怎么做。


Mary


Hi guys. I''m not sure If we are allowed to post questions here. Am sorry if this is not the right place.

I just really need help.

I have a database with Forms and subforms that are bound to a many to many relationship.

How could I import an excel file and automatically enter those
values in the corresponding tables?

解决方案

This isn''t the place to start a technical thread really Hyperpau, but you can post another thread here with a pointer to this one after I''ve moved it to the forum if you like.
I like the idea that the "staff" should expect the highest level of help from their "colleagues". I''m subscribed now but it''s late, so i''ll try to look at this again tomorrow.
In the mean-time, try to explain your data structure using this example template for the table Meta-Data :
Table Name=tblStudent

Expand|Select|Wrap|Line Numbers


Don''t bother with the other (pointer) thread. I left a pointer there anyway when I moved the thread :)


In truth, I''ve done this a few times in the past and the only thing that really works is using recordsets. The logic can get a bit complicated but once you work that out its the easiest way to accomplish it.

e.g. if you were dealing with two tables then you would open a recordset as follows:
  • Excel spreadsheet, either imported to a table or linked.
Open a loop for the recordset and read in the first record.

Add field values appropriate to table1 using docmd.runsql on an appropriate insert statement. If your ID key is an autonumber on the table then you will have to somehow retrieve that value after inserting the record maybe using DMax on the autonumber.

Then create an insert statement to add your data to table2. Assuming ID is again an autonumber you would retrieve it as above.

Lastly you would create an insert statement to add the composite primary key of the two primary keys from tables 1 and 2.

Problem here will be working out the logic of how to manage all three logically to deal with the many to many relationship.

Without seeing the excel spreadsheet its hard to say how you would do this.


Mary


这篇关于帮助基于多对多关系的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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