自动填充子表单 [英] automatically populating subform

查看:63
本文介绍了自动填充子表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会把头发拉出来,并且非常感谢

任何帮助。


我正在创建一个数据输入表格输入学生调查结果。


调查共有40个问题。前7个与

的受访者信息有关,如年级,班级和年龄。我有一张

表,其中有一个自愿编码的PK为RespondentId。问题8-40

都具有相同的格式。对于这些问题,我有一个表格设置

,其中respondentID为FK,问题编号为问题。并且回答

字段。


我的主表单上有响应者信息。对于剩下的问题,我有一个表格子表单

,只有字段questionnumber。和

回答在上面。这是我的问题:我想在这个表单上自动填充数字8到40到

,所以只需要输入

问题的答案。如何我最好这样做吗?我试过设置问题编号的默认值

。字段:


= 1 + DMax(问题编号,tblStudentSurveyAnswers,respondentid =

表格!frmStudentSurvey!respondentID)。我接近了,但是数字

在递增之前重复一次。


任何想法?


TIA,

玛丽

解决方案

4月10日下午3:28,玛丽 < mmcgilliv ... @ msn.comwrote:


我会把这头发拉出来并且会非常感激

任何帮助。


我正在创建一个数据输入表格来输入学生调查结果。


有40个问题调查。前7个与

的受访者信息有关,如年级,班级和年龄。我有一张

表,其中有一个自愿编码的PK为RespondentId。问题8-40

都具有相同的格式。对于这些问题,我有一个表格设置

,其中respondentID为FK,问题编号为问题。并且回答

字段。


我的主表单上有响应者信息。对于剩下的问题,我有一个表格子表单

,只有字段questionnumber。和

回答在上面。这是我的问题:我想在这个表单上自动填充数字8到40到

,所以只需要输入

问题的答案。如何我最好这样做吗?我试过设置问题编号的默认值

。字段:


= 1 + DMax(问题编号,tblStudentSurveyAnswers,respondentid =

表格!frmStudentSurvey!respondentID)。我接近了,但是数字

在递增之前重复一次。


任何想法?


TIA,< br $>
Mary



花了我比想象的更长的时间,对不起。

把它放在你的形式当前。并澄清

tblStudentSurveyAnswers子表单是我的子表单的名称,你的可能会有不同的b
。希望它适合你:)


Private Sub Form_Current()

Dim rsClone作为记录集

Dim db作为数据库

设置db = CurrentDb()


设置rsClone = Forms![frmStudentSurvey]![tblStudentSurveyAnswers

Subform] .Form.RecordsetClone

如果rsClone.RecordCount = 0那么

对于i = 8到40

db.Execute插入到tblStudentSurveyAnswers

([RespondentID],[questionnumber])值(''"& Me![RespondentID]&"'',

''"& i&" '')"

下一个我

结束如果

设置rsClone = Nothing

Me.Refresh

End Sub


4月10日下午5:23,Queezy < que ... @ gmail.comwrote:


4月10日下午3:28,Mary < mmcgilliv ... @ msn.comwrote:



我会在这个上拉我的头发并且会这样感谢

任何帮助。


我正在创建一个数据输入表单来输入学生调查结果。


调查共有40个问题。前7个与

的受访者信息有关,如年级,班级和年龄。我有一张

表,其中有一个自愿编码的PK为RespondentId。问题8-40

都具有相同的格式。对于这些问题,我有一个表格设置

,其中respondentID为FK,问题编号为问题。并且回答

字段。


我的主表单上有响应者信息。对于剩下的问题,我有一个表格子表单

,只有字段questionnumber。和

回答在上面。这是我的问题:我想在这个表单上自动填充数字8到40到

,所以只需要输入

问题的答案。如何我最好这样做吗?我试过设置问题编号的默认值

。字段:


= 1 + DMax(questionnumber,tblStudentSurveyAnswers,respondentid =

!形式frmStudentSurvey respondentID")。我接近了,但数字

在递增之前重复一次。


有什么想法吗?


TIA,

Mary



花了我更长时间比我想象的那样,抱歉。

把它放在你的表格On Current上。并澄清

tblStudentSurveyAnswers子表单是我的子表单的名称,你的可能会有不同的b
。希望它适合你:)


Private Sub Form_Current()

Dim rsClone作为记录集

Dim db作为数据库

设置db = CurrentDb()


设置rsClone = Forms![frmStudentSurvey]![tblStudentSurveyAnswers

Subform] .Form.RecordsetClone

如果rsClone.RecordCount = 0那么

对于i = 8到40

db.Execute插入到tblStudentSurveyAnswers

([RespondentID],[questionnumber])值(''"& Me![RespondentID]&"'',

''"& i&" '')"

下一个我

结束如果

设置rsClone = Nothing

Me.Refresh

结束子隐藏引用文本 -


- 显示引用文本 -



非常感谢你花时间帮我解决这个问题!


我已经粘贴了你的代码,我几乎就在那里。在我使用导航栏

前进到下一条记录然后再回到它之前,子窗体不会填充
。我错过了什么?


玛丽


4月10日下午6:43,玛丽 < mmcgilliv ... @ msn.comwrote:


4月10日下午5:23,Queezy < que ... @ gmail.comwrote:


4月10日下午3:28,玛丽 < mmcgilliv ... @ msn.comwrote:


我会把头发拉出来并且非常感谢

任何帮助。


我正在创建一个数据输入表单,用于输入学生调查的结果。


调查共有40个问题。前7个与

的受访者信息有关,如年级,班级和年龄。我有一张

表,其中有一个自愿编码的PK为RespondentId。问题8-40

都具有相同的格式。对于这些问题,我有一个表格设置

,其中respondentID为FK,问题编号为问题。并且回答

字段。


我的主表单上有响应者信息。对于剩下的问题,我有一个表格子表单

,只有字段questionnumber。和

回答在上面。这是我的问题:我想在这个表单上自动填充数字8到40到

,所以只需要输入

问题的答案。如何我最好这样做吗?我试过设置问题编号的默认值

。字段:


= 1 + DMax(" questionnumber"," tblStudentSurveyAnswers", respondentid =

表格!frmStudentSurvey!respondentID)。我接近了,但数字

在递增之前重复一次。


有什么想法吗?


TIA,

Mary


花了我比想象的更长的时间,对不起。

把它放在你的表格On Current上。并澄清

tblStudentSurveyAnswers子表单是我的子表单的名称,你的可能会有不同的b
。希望它适合你:)


Private Sub Form_Current()

Dim rsClone As Recordset

Dim db作为数据库

设置db = CurrentDb()


设置rsClone = Forms![frmStudentSurvey]![ tblStudentSurveyAnswers

Subform] .Form.RecordsetClone

如果rsClone.RecordCount = 0则

for i = 8 To 40

db.Execute" Insert into tblStudentSurveyAnswers

([RespondentID],[questionnumber])值(''"& Me![RespondentID]&"'',
''"& i&"'')"

Next i

结束如果

Set rsClone = Nothing

Me.Refresh

End Sub-隐藏引用文本 -


- 显示引用的文字 -



非常感谢您抽出宝贵的时间来帮助我!


我已粘贴您的代码,我几乎就在那里。在我使用导航栏

前进到下一条记录然后再回到它之前,子窗体不会填充
。我错过了什么?


Mary-隐藏引用的文字 -


- 显示引用的文字 -



澄清我的上一篇文章 - 子窗体没有填充,直到我将
推进主窗体到下一条记录并回到它。然后它

效果很好!


I''ll pulling my hair out on this one and would be so appreciative of
any help.

I am creating a data entry form to enter results of a student survey.

There are 40 questions on the survey. The first 7 have to do with
respondent information like grade, class and age. I have those in a
table with a PK of RespondentId, which is autonumbered. Questions 8-40
all have the same format. For these questions I have a table set up
with the respondentID as the FK, and a "questionnumber" and "answer"
field.

My main form has the respondent info on it. I have a tabular subform
for the remaining questions, with only the fields "questionnumber" and
"answer" on it. Here''s my problem: I want the numbers 8 thru 40 to
automatically populate on this form, so only the answer to the
question needs to be input.How do I best go about doing so? I tried
setting up the default value of the "questionnumber" field to:

=1+DMax("questionnumber","tblStudentSurveyAnswers" ,"respondentid =
forms!frmStudentSurvey!respondentID"). I got close, but the number
repeats once before incrementing.

Any ideas?

TIA,
Mary

解决方案

On Apr 10, 3:28 pm, "Mary" <mmcgilliv...@msn.comwrote:

I''ll pulling my hair out on this one and would be so appreciative of
any help.

I am creating a data entry form to enter results of a student survey.

There are 40 questions on the survey. The first 7 have to do with
respondent information like grade, class and age. I have those in a
table with a PK of RespondentId, which is autonumbered. Questions 8-40
all have the same format. For these questions I have a table set up
with the respondentID as the FK, and a "questionnumber" and "answer"
field.

My main form has the respondent info on it. I have a tabular subform
for the remaining questions, with only the fields "questionnumber" and
"answer" on it. Here''s my problem: I want the numbers 8 thru 40 to
automatically populate on this form, so only the answer to the
question needs to be input.How do I best go about doing so? I tried
setting up the default value of the "questionnumber" field to:

=1+DMax("questionnumber","tblStudentSurveyAnswers" ,"respondentid =
forms!frmStudentSurvey!respondentID"). I got close, but the number
repeats once before incrementing.

Any ideas?

TIA,
Mary


Took me longer than I thought to come up with this, sorry.
Put this in your forms On Current. And to clarify
tblStudentSurveyAnswers Subform is the name of my subform, yours may
be different. Hope it works for you :)

Private Sub Form_Current()
Dim rsClone As Recordset
Dim db As Database
Set db = CurrentDb()

Set rsClone = Forms![frmStudentSurvey]![tblStudentSurveyAnswers
Subform].Form.RecordsetClone
If rsClone.RecordCount = 0 Then
For i = 8 To 40
db.Execute "Insert Into tblStudentSurveyAnswers
([RespondentID], [questionnumber]) Values(''" & Me![RespondentID] & "'',
''" & i & "'')"
Next i
End If
Set rsClone = Nothing
Me.Refresh
End Sub


On Apr 10, 5:23 pm, "Queezy" <que...@gmail.comwrote:

On Apr 10, 3:28 pm, "Mary" <mmcgilliv...@msn.comwrote:


I''ll pulling my hair out on this one and would be so appreciative of
any help.

I am creating a data entry form to enter results of a student survey.

There are 40 questions on the survey. The first 7 have to do with
respondent information like grade, class and age. I have those in a
table with a PK of RespondentId, which is autonumbered. Questions 8-40
all have the same format. For these questions I have a table set up
with the respondentID as the FK, and a "questionnumber" and "answer"
field.

My main form has the respondent info on it. I have a tabular subform
for the remaining questions, with only the fields "questionnumber" and
"answer" on it. Here''s my problem: I want the numbers 8 thru 40 to
automatically populate on this form, so only the answer to the
question needs to be input.How do I best go about doing so? I tried
setting up the default value of the "questionnumber" field to:

=1+DMax("questionnumber","tblStudentSurveyAnswers" ,"respondentid =
forms!frmStudentSurvey!respondentID"). I got close, but the number
repeats once before incrementing.

Any ideas?

TIA,
Mary


Took me longer than I thought to come up with this, sorry.
Put this in your forms On Current. And to clarify
tblStudentSurveyAnswers Subform is the name of my subform, yours may
be different. Hope it works for you :)

Private Sub Form_Current()
Dim rsClone As Recordset
Dim db As Database
Set db = CurrentDb()

Set rsClone = Forms![frmStudentSurvey]![tblStudentSurveyAnswers
Subform].Form.RecordsetClone
If rsClone.RecordCount = 0 Then
For i = 8 To 40
db.Execute "Insert Into tblStudentSurveyAnswers
([RespondentID], [questionnumber]) Values(''" & Me![RespondentID] & "'',
''" & i & "'')"
Next i
End If
Set rsClone = Nothing
Me.Refresh
End Sub- Hide quoted text -

- Show quoted text -

Thank you so much for taking the time to help me with this!

I''ve pasted your code and I''m almost there. The subform is not
populating until I advance to the next record using the navigation bar
and then come back to it. What am I missing?

Mary


On Apr 10, 6:43 pm, "Mary" <mmcgilliv...@msn.comwrote:

On Apr 10, 5:23 pm, "Queezy" <que...@gmail.comwrote:


On Apr 10, 3:28 pm, "Mary" <mmcgilliv...@msn.comwrote:

I''ll pulling my hair out on this one and would be so appreciative of
any help.

I am creating a data entry form to enter results of a student survey.

There are 40 questions on the survey. The first 7 have to do with
respondent information like grade, class and age. I have those in a
table with a PK of RespondentId, which is autonumbered. Questions 8-40
all have the same format. For these questions I have a table set up
with the respondentID as the FK, and a "questionnumber" and "answer"
field.

My main form has the respondent info on it. I have a tabular subform
for the remaining questions, with only the fields "questionnumber" and
"answer" on it. Here''s my problem: I want the numbers 8 thru 40 to
automatically populate on this form, so only the answer to the
question needs to be input.How do I best go about doing so? I tried
setting up the default value of the "questionnumber" field to:

=1+DMax("questionnumber","tblStudentSurveyAnswers" ,"respondentid =
forms!frmStudentSurvey!respondentID"). I got close, but the number
repeats once before incrementing.

Any ideas?

TIA,
Mary

Took me longer than I thought to come up with this, sorry.
Put this in your forms On Current. And to clarify
tblStudentSurveyAnswers Subform is the name of my subform, yours may
be different. Hope it works for you :)

Private Sub Form_Current()
Dim rsClone As Recordset
Dim db As Database
Set db = CurrentDb()

Set rsClone = Forms![frmStudentSurvey]![tblStudentSurveyAnswers
Subform].Form.RecordsetClone
If rsClone.RecordCount = 0 Then
For i = 8 To 40
db.Execute "Insert Into tblStudentSurveyAnswers
([RespondentID], [questionnumber]) Values(''" & Me![RespondentID] & "'',
''" & i & "'')"
Next i
End If
Set rsClone = Nothing
Me.Refresh
End Sub- Hide quoted text -

- Show quoted text -


Thank you so much for taking the time to help me with this!

I''ve pasted your code and I''m almost there. The subform is not
populating until I advance to the next record using the navigation bar
and then come back to it. What am I missing?

Mary- Hide quoted text -

- Show quoted text -

To clarify my last post - The subform is not populating until I
advance the main form to the next record and come back to it. Then it
works great!


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

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