Pop up form if previous field = 1

Mmattson

Registered User.
Local time
Today, 10:15
Joined
Oct 28, 2002
Messages
46
I've been working with FileMaker and am beginning to learn Access more in depth. What I am trying to do is this:

Survey form with 10 fields (Q1 - Q10).
Questions will be answered by either 1 or 0.
If field (Q1)=1 then pop up comment field (Q1C).
The same will be done for all questions.

What is the best way to accomplish this?
If not possible, can I hid the field until Q1=1?

I did search for an answer but didn't find quite what I needed.
 
Last edited:
First, make the Visible property of field Q1C = no. Then on the AfterUpdate event for field Q1, place code:

If me.q1 = 1 then
me.q1C.visible = true
else
' do nothing (comment this line out)
end if

Then on the OnCurrent property of the form, place this code:

me.q1C.visible = false

That should do it. Give it a try and let me know.
 
I've run this solution and I think it will work perfectly.

Is there a quick and easy way to make this field required when popped up? If it doesn't pop up it is not required?

Thanks for response.
 
First, I think you need to tweak the On Current event a little.


Private Sub Form_Current()
If Me.NewRecord Then
Me.q1c.Visible = False
ElseIf Me.NewRecord = False And Me.q1 = "1" Then
Me.q1c.Visible = True
ElseIf Me.NewRecord = False And Me.q1 <> "1" Then
Me.q1c.Visible = False
Else
'do nothing
End If


End Sub

Then to validate whether something is entered in the Comments field, you place code in the BeforeUpdate event of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.q1c.Visible = True And IsNull(Me.q1c) Then
MsgBox "Please enter a response"
Cancel = True
Exit Sub
Else
'do nothing, update the record
End If


End Sub

I'm doing this on the fly, so this code might need further tweaking as you actually enter data - let me know if it works though.
 

Users who are viewing this thread

Back
Top Bottom