基本问题:RecordSet和QueryDef用法之间的区别。 [英] Basic question: Difference between RecordSet and QueryDef Usage.

查看:162
本文介绍了基本问题:RecordSet和QueryDef用法之间的区别。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨再次


我可以从SQL语句创建一个记录集(我发现它更容易操作)吗? (而不是querydef)。


我有一个子窗体,上面有对作业(服务检查)的评论。子表单(数据表视图)上的每个作业都有完成日期,序列号,客户名称,部门,customer_id(不可见文本框),作业编号。


我想创建一个记录集,我可以用它作为报告的基础。


假设我单击子表单中的某个作业,我将获取作业日期和相关的客户ID,并根据在同一日期完成的任何其他作业创建记录集相同的客户ID。


所以我需要这些内容:


strSQL =" SELECT JobNumber from tblCheckSheet where tblCheckSheet.JobDate =" ; &安培; txtJobDate.Value" AND" tblCheckSheet.CustomerID =" &安培; txtCustomerID.Value


一旦语句可行,我就可以这样做了......所有的rs和db和qdf等都已经完成了。


设置qdf = db.CreateQueryDef("",strSQL)

设置rs = qdf.OpenRecordset


然后说我有一份报告有各种文本框等,我可以让他们的记录来说:


txtAssessment = rs!评估


等等?



请原谅我的无知......我已经完成了零访问课程,并且已经被深深地抛入了这个数据库。我手头有几本1000-1500页的书,但没有时间从头到尾阅读每一本书,他们提供的大部分信息都是处理文本框属性等基本内容,或者深入研究SQL服务器解决方案和ADO以及喜欢!


再次非常感谢你的帮助。

Hi again

Can I create a recordset (which I find a lot easier to manipulate) from an SQL statement? (instead of a querydef).

I have a subform that has reviews of job (service checks) on it. Each job on the subform (datasheet view) has the date it was done, serial number, customer name, department, customer_id(invisible textbox), job number.

I want to create a recordset that I can use for the basis of reports.

Say I click on a job in the subform I would to pick up the job date and related customer ID and create a recordset based on any other jobs done on that same date and with the same customer ID.

So I need something along these lines:

strSQL = "SELECT JobNumber From tblCheckSheet Where tblCheckSheet.JobDate = " & txtJobDate.Value "AND "tblCheckSheet.CustomerID = " & txtCustomerID.Value

Once the statement is workable can I then do something like this... all Dim of rs and db and qdf etc already done.

Set qdf = db.CreateQueryDef ("",strSQL)
Set rs = qdf.OpenRecordset

Then say I have a report with various text boxes etc, can I just make their recordsource say:

txtAssessment = rs!Assessment

etc etc?


Please excuse my ignorance..I have done zero courses on access and have been pretty much thrown in the deep end to make this database. I have several 1000 - 1500 page books on hand but not the time to read every one from start to end and much of the information they give is either dealing with really basic things like textbox properties etc or delving into SQL server solutions and ADO and the like!

Again many thanks for all your help.

推荐答案

或者我应该有这样的东西而不是我之前写过...


strSQL =" SELECT JobNumber" &安培; VbCrLf& _

" FROM [tblCheckSheet]" &安培; VbCrLf& _

" WHERE(tblCheckSheet.JobDate =''"& Me.txtJobDate&"'')& vbCrLf& _

AND(tblCheckSheet.CustomerID =''"& Me.txtCustomerID&''")

"


说实话,对我来说真是个烂摊子?
Or should I have something like this instead of what I wrote previously...

strSQL = "SELECT JobNumber " & VbCrLf & _
"FROM [tblCheckSheet] " & VbCrLf & _
"WHERE (tblCheckSheet.JobDate =''" & Me.txtJobDate & "'') & vbCrLf & _
AND (tblCheckSheet.CustomerID =''" & Me.txtCustomerID &''")
"

Looks like a real mess to me to be honest?


不,我不能说


txtAssessment = rs!评估为会有一组记录,所以我需要能够以某种方式从记录集中选择单个记录,然后从每个记录中挖出各个字段。


只需3小时因吵闹的邻居而睡觉所以请原谅这个混乱!
No I wont be able to say

txtAssessment = rs!Assessment as there will be a group of records so I''ll need to be able to somehow select individual records from the recordset and then dig out the individual fields from each record.

Only 3 hours sleep due to noisy neighbours so please excuse the confusion!


我认为QueryBuilder创建的语句(在SQL视图中)不能只是剪切并粘贴到表单的模块中吗? br />

或者那些不需要任何引用表单控件的人可能是那些需要引用表单的人需要所有''和''包括在内呢?我注意到查询构建器将构建一个SQL查询,其中包含对组合框的引用,但它似乎不需要''和''。等等?


在这里偏离原来的话题......
I take it the statements that the QueryBuilder creates (in SQL View) cannot just be cut and pasted into the Module of a form?

Or maybe those that dont require any reference to Form Controls can be but those that need to refer to a form need all the '' and " included? I notice that the query builder will build an SQL query that does include reference to say a combobox but it doesn''t seem to need the '' and " etc?

Straying a bit off my original topic here...


这篇关于基本问题:RecordSet和QueryDef用法之间的区别。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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