在MS Access中创建跳过规则? [英] Creating skip rule in MS Access?
问题描述
我正在MS Access中开发一个数据库。我想创建一个跳过规则。以下是问题的一个例子:
第一个问题:''你是学生''。接下来的问题是你去哪所学校?。然后下一个是你多大了?。
在上述情况下,如果某人对第一个问题回答否,则第二个问题不适用于该人,因此我们可以跳到第三个问题。我想知道如何在MS Access中创建此跳过规则,因此在第一个问题输入否后,如果有人点击标签,则跳过第二个问题时会将他/她带到第三个问题。
任何帮助表示赞赏。
谢谢
您只需使用IF..THEN语句,每个问题都作为SUB的一部分。例如:
Private Sub Command5_Click()
如果Question1 = A则
致电SUB1
其他
致电SUB2
结束如果
结束次级
私人子SUB1()
''(在问题2输入代码)
结束子
私有子SUB2()
''(在问题3输入代码)
结束子
希望这会有所帮助。
comteck
感谢您的帮助。但是我是Access的新手。在哪里写命令?我是否必须使用Macro?
谢谢
Aha
否..代码不是用宏写的。在这种情况下,代码使用代码生成器编写。
创建一个新的命令按钮(关闭向导 - 或在出现时取消)。仍处于设计模式,右键单击按钮,然后选择构建事件。然后选择代码生成器。这将自动为该按钮创建OnClick事件过程。 Visual Basic将打开,以下代码将出现(或类似):
Private Sub Command5_Click()
End Sub
然后将以下代码放在这两行之间:
如果Question1 = A则
调用SUB1
否则
致电SUB2
结束如果
最终代码为:
Private Sub Command5_Click()
如果Question1 = A那么
致电SUB1
否则
调用SUB2
结束如果
结束子
然后,在仍然在Visual Basic中时,添加其他潜艇。最终的代码是:
Private Sub Command5_Click()
如果Question1 = A那么
调用SUB1
Else
致电SUB2
结束如果
结束次级
私人子SUB1 ()
''(在问题2输入代码)
结束子
私人子SUB2()
''(在问题3输入代码)
结束子
希望这是有意义的。
comteck
I am developing a database in MS Access. I want to create a skip rule. Following is an example of the problem:
The first question: ''Are you a student''. The next question is ''which school do you go to?''. and then the next one is ''how old are you?''.
In the above context if someone answers ''No'' to the first question then the second question does not apply to that person so we can jump to the third question. I want to know how to create this skip rule in MS Access so after entering ''no'' to the first question if one hit ''tab'' it will take him/ her to the third question while skip the second one.
Any help is appreciated.
Thanks
You simply use an IF..THEN statement, with each question as part of a SUB. For example:
Private Sub Command5_Click()
If Question1 = A Then
Call SUB1
Else
Call SUB2
End If
End Sub
Private Sub SUB1()
''(Enter Code Here for Question 2)
End Sub
Private Sub SUB2()
''(Enter Code Here for Question 3)
End Sub
Hope this helps.
comteck
Thanks for your help. However I am a novice in Access. Where to write the commands? Do I have to use Macro?
Thanks
Aha
No.. Code is not written in a macro. In this case, the code is written using "Code Builder".
Create a new Command Button (turn off the wizard - or cancel when it appears). Still in design mode, right click on the button, and select "Build Event". Then choose "Code Builder". This will automatically create an OnClick Event Procedure for that button. Visual Basic will open, and the following code will appear (or something similar):
Private Sub Command5_Click()
End Sub
You then put the following code in between these 2 lines:
If Question1 = A Then
Call SUB1
Else
Call SUB2
End If
The final code will be:
Private Sub Command5_Click()
If Question1 = A Then
Call SUB1
Else
Call SUB2
End If
End Sub
Then, while still in Visual Basic, add the other subs. The final code will be:
Private Sub Command5_Click()
If Question1 = A Then
Call SUB1
Else
Call SUB2
End If
End Sub
Private Sub SUB1()
''(Enter Code Here for Question 2)
End Sub
Private Sub SUB2()
''(Enter Code Here for Question 3)
End Sub
Hope this makes sense.
comteck
这篇关于在MS Access中创建跳过规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!