我正在尝试根据分配给他们的采购订单计算发送给供应商的所有商品。但我似乎无法控制显示基于采购订单实例的多个项目 - 它不断抛出#name?或#error!表单激活时,文本框中的消息。
为tblPODetail创建语句
USE [instkeeper_test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblPODetail](
[intPurchaseOrderInstance] [int] IDENTITY(1,1) NOT NULL,
[intPONumber] [int] NOT NULL,
[datDateEntered] [datetime] NOT NULL,
[bolPOOpen] [bit] NOT NULL,
[intRMANumber] [nvarchar](255) NULL,
[strSupplierCode] [nvarchar](50) NOT NULL,
[strSupplierLastAddress] [nvarchar](50) NULL,
[strSupplierLastCity] [nvarchar](50) NULL,
[strSupplierLastState] [nvarchar](50) NULL,
[strSupplierLastPostalCode] [nvarchar](50) NULL,
[strSupplierLastCountry] [nvarchar](50) NULL,
[strSupplierLastPhone] [nvarchar](50) NULL,
[strSupplierLastFax] [nvarchar](50) NULL,
[datDateSent] [datetime] NULL,
[datDateReceived] [datetime] NULL,
[bolAdvGageTrakNoTouch] [bit] NOT NULL,
[bolAdvHardCopies] [bit] NOT NULL,
[bolFreightShip] [bit] NOT NULL,
[bolReturnableUsed] [bit] NOT NULL,
[bolInHouse] [bit] NOT NULL,
[strUPSTrackNumOut] [nvarchar](255) NULL,
[strFedExTrackNumOut] [nvarchar](255) NULL,
[strFreightTrackNumOut] [nvarchar](255) NULL,
[strUPSTrackNumIn] [nvarchar](255) NULL,
[strFedExTrackNumIn] [nvarchar](255) NULL,
[strFreightTrackNumIn] [nvarchar](255) NULL,
[SSMA_TimeStamp] [timestamp] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tblPODetail] WITH CHECK ADD CONSTRAINT [SSMA_CC$tblPODetail$strSupplierCode$disallow_zero_length] CHECK ((len([strSupplierCode])>(0)))
GO
ALTER TABLE [dbo].[tblPODetail] CHECK CONSTRAINT [SSMA_CC$tblPODetail$strSupplierCode$disallow_zero_length]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__intPO__6C190EBB] DEFAULT ((0)) FOR [intPONumber]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__datDa__6D0D32F4] DEFAULT (getdate()) FOR [datDateEntered]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__bolPO__6E01572D] DEFAULT ((1)) FOR [bolPOOpen]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__bolAd__6EF57B66] DEFAULT ((1)) FOR [bolAdvGageTrakNoTouch]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__bolAd__6FE99F9F] DEFAULT ((1)) FOR [bolAdvHardCopies]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__bolFr__70DDC3D8] DEFAULT ((0)) FOR [bolFreightShip]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__bolRe__71D1E811] DEFAULT ((0)) FOR [bolReturnableUsed]
GO
ALTER TABLE [dbo].[tblPODetail] ADD CONSTRAINT [DF__tblPODeta__bolIn__72C60C4A] DEFAULT ((0)) FOR [bolInHouse]
GO
为tblPOGaugeDetail创建语句
USE [instkeeper_test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[tblPOGaugeDetail](
[intItemPOID] [int] IDENTITY(1,1) NOT NULL,
[intGagePOID] [int] NOT NULL,
[strGageDetailID] [nvarchar](50) NULL,
[datGageSent] [datetime] NULL,
[datGageReceived] [datetime] NULL,
[bolGageCalibrate] [bit] NOT NULL,
[bolGageRepair] [bit] NOT NULL,
[bolGageEvaluate] [bit] NOT NULL,
[bolGageAccredited] [bit] NOT NULL,
[bolGageReturned] [bit] NOT NULL,
[bolGageException] [bit] NOT NULL,
[bolGageExceptResolved] [bit] NOT NULL,
[bolGageLeavePriceBlank] [bit] NOT NULL,
[intGageCost] [real] NULL,
[intTurnaroundDaysOut] [int] NULL,
[SSMA_TimeStamp] [timestamp] NOT NULL,
CONSTRAINT [tblPOGaugeDetail$PrimaryKey] PRIMARY KEY CLUSTERED
(
[intItemPOID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] WITH CHECK ADD CONSTRAINT [tblPOGaugeDetail$tblPODetailtblPOGaugeDetail] FOREIGN KEY([intGagePOID])
REFERENCES [dbo].[tblPODetail] ([intPurchaseOrderInstance])
ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] CHECK CONSTRAINT [tblPOGaugeDetail$tblPODetailtblPOGaugeDetail]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [intGagePOID]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((1)) FOR [bolGageCalibrate]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageRepair]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageEvaluate]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageAccredited]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageReturned]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageException]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageExceptResolved]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [bolGageLeavePriceBlank]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [intGageCost]
GO
ALTER TABLE [dbo].[tblPOGaugeDetail] ADD DEFAULT ((0)) FOR [intTurnaroundDaysOut]
GO
我希望计数显示在
中的采购订单明细的查询声明SELECT dbo_tblPODetail.intPurchaseOrderInstance, dbo_tblPODetail.strSupplierCode, dbo_tblPODetail.bolPOOpen, dbo_tblPODetail.intPONumber, dbo_tblPODetail.datDateSent
FROM dbo_tblPODetail
WHERE (((dbo_tblPODetail.bolPOOpen)=True))
ORDER BY dbo_tblPODetail.datDateSent;
我有点沮丧,因为我在DCount()和SELECT COUNT(*)上都读过一些内容,但似乎无法获得它们的任何一个。任何帮助将不胜感激!提前谢谢!
- 编辑于06/18/2009 @ 1542小时 -
这是我尝试在子窗体的On Current事件触发时尝试使用的SELECT COUNT的示例:
SELECT COUNT(*) AS ItemsSent
FROM [dbo_tblPOGaugeDetail]
WHERE [dbo_tblPOGageDetail]![intGagePOID] = [dbo_tblPODetail]![intPurchaseOrderInstance]
这是附加到子窗体中控件的= DCOUNT语句的示例。
=DCOUNT("*", "[dbo_tblPOGaugeDetail]", "[intGagePOID] = [Forms]![frmSupplierInfoMain]![subfrmOpenPOBySupplierID]![intPurchaseOrderInstance]")
这些都没有奏效 - 遗憾的是。
答案 0 :(得分:1)
您的查询是否在没有计数(*)的情况下工作?
使用实际字段名称作为DCount的第一个争论 从where字符串中获取控件名称。
For DCOUNT("[intItemPOID],"[dbo_tblPOGaugeDetail]","[intGagePOID]=" & Forms]![frmSupplierInfoMain]![subfrmOpenPOBySupplierID]![intPurchaseOrderInstance])