使用visual basic从另一个表填充表单的字段? [英] Using visual basic to populate fields of a form from another table?

查看:64
本文介绍了使用visual basic从另一个表填充表单的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个Access数据库,我们的部门用它来存储和分析特定工作的信息。因为我们公司在庞大的SQL数据库上运行,所以如果已经存储在SQL DB中的基本工作详细信息(名称,位置,销售人员等)可以在单击时加载到我的一个表单上,我认为可以节省一些时间一个按钮。表单需要此信息(以及必须手动输入的更多信息)才能完成。我写了一个SQL视图并将其链接到我的Access DB中。我的想法是,在输入新工作时,能够在我的表单上输入一个工作号,然后单击一个按钮,从已存储在视图中的信息中填充其他几个字段。但是,我得到运行时错误424找不到对象。 - 即使所有相关字段都已包含在我的表单中的SELECT语句中,也已完成相应的INNER JOIN。这就是我在做的方式:

展开 | 选择 | Wrap | 行号

解决方案

使用visual basic,我尝试编写一个查询来搜索我需要的信息,然后使用宏来查询表单上的字段=查询字段。


这个是我现在得到的错误:


你不能参考直接查看。你需要使用类似记录集的东西。因为这会返回视图中的所有记录,并且您只能一次将一条记录加载到表中,您需要设置标准。

展开 | 选择 | Wrap | 行号


非常感谢!


最后一个问题 - 如果我想添加一个MsgBox并结束该过程,如果视图中不存在该特定的作业编号(例如,如果他们输入错误,那么)我去做那个?


再次,非常感谢。 :)

I have written an Access database that our department uses to store and analyze information on particular jobs. Because our company runs on an enormous SQL DB, I thought it would save some time if the basic job details (name, location, salesperson, etc) which is already stored in the SQL DB could be loaded onto one of my forms at the click of a button. The form needs this information (and more that has to be manually entered) to be complete. I wrote an SQL view and linked it into my Access DB. My idea is to be able to, when entering new jobs, type in a job number on my form, and then at the click of a button, populate several other fields from information already stored in the view. However, I''m getting run-time error 424 "object not found" - even though all relevant fields have been included on my SELECT statement in my form the appropriate INNER JOIN has been done. Here''s how I''m doing it:

Expand|Select|Wrap|Line Numbers

解决方案

Instead of using visual basic, I tried writing a query to search for the information I needed, and then using a macro to have the field on the form = the field on the query.

This is the error I am now getting:


You cannot reference the view directly. You need to use something like a recordset. As this returns all records in the view and you can only load one record at a time into the table you will need to set criteria.

Expand|Select|Wrap|Line Numbers


Thanks so much!

Last question - if I wanted to add a MsgBox and end the process if that particular job number does not exist in the view (if they typed it in incorrectly, for example) how would I go about doing that?

Again, very much appreciated. :)


这篇关于使用visual basic从另一个表填充表单的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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