如何在基于查询的表单上显示值 [英] how can I have a value show on a form based on a query

查看:52
本文介绍了如何在基于查询的表单上显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,它有几个文本框,字段和子表单。它有一个提示输入SerialNbr的参数。

表单上的字段是SerialNbr,cboCartStatus,CartDate,CartID,ServiceID

子表单字段:cboCartEvent,CartID,CartEventSubType, CartEventDate


表单的控件源是一个使用表tbl_Cart的查询。 tbl_Cart中的字段是:CartID,SerialNbr,ServiceID,CartStatus,CartStatusDate

和tbl_Cart与tbl_Services相关,其字段为:ServiceID,AddressID,ServiceStatus,NbrCarts等


AddressID来自一个视图,它是整个应用程序的基础。因此,基于Services表和vAddress视图创建了一个视图,这是vService_Address的来源。它返回所有匹配的记录,其地址与服务相关。


因此,表单的作用是......当表单打开时,它会询问用户一个SerialNbr。输入串行nbr后,它会显示与该SerialNbr相关的记录。


我给出了以下伪代码,说这就是我需要做的。有人可以帮助我将这个伪代码转换为VBA代码。


在购物车表格上,在购物车更新下插入地址标签?标题。

在Form Load子程序中,将默认标题设置为?Address Unknown ?.

使用序列号作为参数查询Cart表。

如果查询返回记录,请检查ServiceID。

如果它不为null,则使用ServiceID作为参数查询视图vService_Address。

设置地址标签到查询返回的连接地址

I have a form it has several text boxes, fields and a subform. it has a parameter that prompts for a SerialNbr.
The fields on the form are SerialNbr, cboCartStatus, CartDate, CartID, ServiceID
Subform fields: cboCartEvent, CartID, CartEventSubType, CartEventDate

The control source for the form is a query that uses the table tbl_Cart. the fields in the tbl_Cart are: CartID, SerialNbr, ServiceID, CartStatus, CartStatusDate
and the tbl_Cart is related to the tbl_Services and its fields are: ServiceID, AddressID, ServiceStatus, NbrCarts, etc

The AddressID comes from a view which is the basis for the entire application. So a veiw was created based on the Services table and the vAddress view this is where the vService_Address comes from. It returns all matching records that has an address that''s related to a service.

Hence, what the form does is...when the form is opened it asks the user for a SerialNbr. ONce the serial nbr is entered it brings up the record that is associated with that SerialNbr.


The following pseudocode was given to me saying this is how I need to do it. Can someone help me turn this pseudocode in to VBA code.


On the Cart Form, insert an Address label under the ?Cart Update? title.
In the Form Load subroutine, set the default caption to ?Address Unknown?.
Query the Cart table using the Serial Number as the parameter.
If the query returns a record, check the ServiceID.
If it is not null, then query view vService_Address using the ServiceID as the parameter.
Set the Address label to the concatenated address returned by the query

推荐答案

我不确定你要做什么,但听起来你可能想要DLookup( )功能。下面是一个示例,您将放入SerialNbr控件的AfterUpdate事件:
I''m not exactly sure what you are trying to do, but it sounds like you might be wanting the DLookup() function. Here is an example that you would put in the AfterUpdate event for the SerialNbr control:
展开 | 选择 | Wrap | 行号


感谢您的回复.. 。


我基本上只是想让表格显示在显示的任何记录上。我发布的伪代码是我想要做到的。但不知道如何去做。
thank for your reply...

I am just basically trying to have the address appear on the form for whatever record is displaying. and the pseudocode I posted is what i wanna do to accomplish this. but not sure how to go about doing it.


你能附上数据库的副本吗?我无法弄清楚伪代码正在尝试什么。拥有数据库将有所帮助。
Can you attach a copy of your database? I''m not being able to figure out what the pseudocode is trying to. Having the database will help.


这篇关于如何在基于查询的表单上显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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