N
Niniel
Hello,
I have never done this before, but I read that it is a good idea to put code
that is used in several places in a module.
So, I'd like to try to do that.
I'd appreciate help in deciding what needs to go into the module, as well as
coming up with a method of using it.
Thank you.
Here's the code I have; it'll be used in 4 - 5 instances. What will change
is the name of the text field [here: NoteText1] and the question id.
In my parent form:
___
Private Sub NoteText1_AfterUpdate()
'Copy text from text field to table and save record
DoCmd.RunSQL "Update tblActivityAnswers Set [Note] =
Forms!frmBrowseApplications.[NoteText1] WHERE [ActivityID] =
Forms!frmBrowseApplications.[ActivityID] And [QuestionID] = 12"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
In my subform:
___
Private Sub Answer_AfterUpdate()
If Me.Answer = -1 And Me.QuestionID = 12 Then
Me.Parent.NoteText1.Visible = True
End If
If Me.Answer = 0 And Me.QuestionID = 12 Then
Me.Parent.NoteText1.Visible = False
End If
End Sub
Private Sub Form_current()
If DLookup("[Answer]", "tblActivityAnswers", "[ActivityID] = " &
Me.Parent.[ActivityID] & " AND [QuestionID] = 12") = True Then
Me.Parent.NoteText1.Visible = True
Me.Parent.NoteText1 = DLookup("[Note]", "tblActivityAnswers", "[ActivityID]
= " & Me.Parent.[ActivityID] & " AND [QuestionID] = 12")
Else: Me.Parent.NoteText1.Visible = False
End If
End Sub
I have never done this before, but I read that it is a good idea to put code
that is used in several places in a module.
So, I'd like to try to do that.
I'd appreciate help in deciding what needs to go into the module, as well as
coming up with a method of using it.
Thank you.
Here's the code I have; it'll be used in 4 - 5 instances. What will change
is the name of the text field [here: NoteText1] and the question id.
In my parent form:
___
Private Sub NoteText1_AfterUpdate()
'Copy text from text field to table and save record
DoCmd.RunSQL "Update tblActivityAnswers Set [Note] =
Forms!frmBrowseApplications.[NoteText1] WHERE [ActivityID] =
Forms!frmBrowseApplications.[ActivityID] And [QuestionID] = 12"
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
In my subform:
___
Private Sub Answer_AfterUpdate()
If Me.Answer = -1 And Me.QuestionID = 12 Then
Me.Parent.NoteText1.Visible = True
End If
If Me.Answer = 0 And Me.QuestionID = 12 Then
Me.Parent.NoteText1.Visible = False
End If
End Sub
Private Sub Form_current()
If DLookup("[Answer]", "tblActivityAnswers", "[ActivityID] = " &
Me.Parent.[ActivityID] & " AND [QuestionID] = 12") = True Then
Me.Parent.NoteText1.Visible = True
Me.Parent.NoteText1 = DLookup("[Note]", "tblActivityAnswers", "[ActivityID]
= " & Me.Parent.[ActivityID] & " AND [QuestionID] = 12")
Else: Me.Parent.NoteText1.Visible = False
End If
End Sub