HalloweenWeed
Member
- Local time
- Today, 09:34
- Joined
- Apr 8, 2020
- Messages
- 220
Hello,
As some of you might have noticed a few months ago, I have a very complicated and automated multi-institutional database. Here is the problem:
I have a form and subform that selects a person's record, to fill in that component of another form. Sometimes the button works, and other times it selects the first record on the list (I haven't been able to discern when/why), even though clicked on another record. What I need to know, is not necessarily how to fix the problem, but how to troubleshoot it. Now before you get any ideas about simplifying my forms or anything like that I need to explain some things. I cannot post this database, as it is a split (2) database, and contains confidential information. These forms will not work without a great deal of other forms being present.
The form uses complicated algorithms to "live search," instantly updating the results in the subform as you type in the single search criteria field. This field looks for even partial matches in multiple records multiple fields, and writes them in a table, after erasing said table, immediately every time a letter is typed, all via VBA, and the subform is bound to a simple query of this table. In order to do this, it was necessary to produce the results in a subform within the parent form (otherwise it interferes with typing in the criterion field). The parent form is a "single form." The subform is a "continuous form."
The button in the subform simply chooses the record and passes on the information to the proper form, also closing it's parent form.
The button's VBA (I've had to delete some to make the forum limit, see attached for full text):
The problem is, sometimes it pulls the info from the first record instead of the record of the button clicked on.
Before you ask: yes, it compiles. Access 2016/Office 365, and it is an .accdb, I can't make an executable out of it, it edits tables in the FE.
It all works fantastic otherwise.
If I click on the desired record of the subform, away from buttons (there are no other active controls), and then click on the button it works right 100% of the time.
I would appreciate any troubleshooting ideas. Thank you.
As some of you might have noticed a few months ago, I have a very complicated and automated multi-institutional database. Here is the problem:
I have a form and subform that selects a person's record, to fill in that component of another form. Sometimes the button works, and other times it selects the first record on the list (I haven't been able to discern when/why), even though clicked on another record. What I need to know, is not necessarily how to fix the problem, but how to troubleshoot it. Now before you get any ideas about simplifying my forms or anything like that I need to explain some things. I cannot post this database, as it is a split (2) database, and contains confidential information. These forms will not work without a great deal of other forms being present.
The form uses complicated algorithms to "live search," instantly updating the results in the subform as you type in the single search criteria field. This field looks for even partial matches in multiple records multiple fields, and writes them in a table, after erasing said table, immediately every time a letter is typed, all via VBA, and the subform is bound to a simple query of this table. In order to do this, it was necessary to produce the results in a subform within the parent form (otherwise it interferes with typing in the criterion field). The parent form is a "single form." The subform is a "continuous form."
The button in the subform simply chooses the record and passes on the information to the proper form, also closing it's parent form.
The button's VBA (I've had to delete some to make the forum limit, see attached for full text):
Code:
Private Sub GrievanceStrt_Click()
On Error GoTo Err_Handler
Dim TempTxt As String
Dim stDocName As String, stOpenArgs As String, Msg As String
Me.Parent.MD_OrMRsearch.SetFocus
Me.Parent.Form.SetFocus
stOpenArgs = Me.Parent.Form.Name
If CurrentProject.AllForms("GrievanceForm").IsLoaded Then
DoCmd.Close acForm, "GrievanceForm", acSaveYes
End If
stDocName = "NewGrievanceForm"
If Me.Parent.Form!ParntForm = stDocName Then
If Not CurrentProject.AllForms(stDocName).IsLoaded Then
MsgBox "Error: New Grievance form (short form) has been closed. Cannot continue."
GoTo CloseForm
End If
Else
If CurrentProject.AllForms(stDocName).IsLoaded Then
DoCmd.Close acForm, stDocName, acSaveYes
End If
Call ChkGrvncNumbers
DoCmd.OpenForm stDocName, , , , acFormAdd, , stOpenArgs
End If
With Forms![NewGrievanceForm]
If Not IsNull([MD_No]) Then ![MD_No] = [MD_No]
If Not IsNull([MR_No]) Then ![MR_No] = [MR_No]
![GrievantLN] = [GrievantLN]
If Not IsNull([GrievantFN]) Then ![GrievantFN] = [GrievantFN]
If Not IsNull([GrievantMN]) Then ![GrievantMN] = [GrievantMN]
![LN_FN_MN] = [LN_FN_MN]
![GrievantID] = [GrievantID]
If Not IsNull([GrievantDOB]) Then ![GrievantDOB] = [GrievantDOB]
![GrievantAddyLn1] = [GrievantAddyLn1]
![GrievantAddyLn2] = [GrievantAddyLn2]
![GrievantAddyCty] = [GrievantAddyCty]
![GrievantAddySt] = [GrievantAddySt]
![GrievantAddyZip] = [GrievantAddyZip]
![GrievantAddyPhone] = [GrievantAddyPhone]
![GrievantAddyCell] = [GrievantAddyCell]
![GrievantAddyEmail] = [GrievantAddyEmail]
If Me.Parent.Form!ParntForm = "NewGrievanceForm" Then
![ModifiedUser] = Forms![SecurityCurrentUserName]![CurrentUser]
![ModifiedDate] = Now()
Else
![IsComplaint] = False
![L1DateFiled] = Date
![LastLevelDateFiled] = Date
![L1ResponseDue] = WorkDayNext(Date, 5)
![L1DateDue] = WorkDayNext(Date, 5)
![DateDue] = WorkDayNext(Date, 5)
![OnTime] = "N/A"
![Level] = 1
![RespAgency] = Forms![SecurityCurrentUserName]![Agency]
' initialize variables (zero) for logic
![L1CorrAct] = 0
![L1ExtReq] = 0
![L1FindSubst] = 0
![L2CorrAct] = 0
![L2ExtAgreed] = 0
![L2ExtReq] = 0
![L2FindSubst] = 0
![L3ComRev] = 0
![L3CorrAct] = 0
![L3HrngOffcrFinding] = 0
![L3HearingStatus] = 0
![GrievID_NoOnly] = 0
![UrgentStatus] = 0
![UrgentClientNotified] = 0
![UrgentHearing] = 0
![UrgentRefBackStatus] = 0
Select Case Forms![SecurityCurrentUserName]![Agency]
Case 3
TempTxt = "Default value, NOT TO BE USED FOR OFFICIAL RESPONSE: I have " & Chr(13) & Chr(10)
TempTxt = TempTxt & Chr(13) & Chr(10) & "FINDINGS: " & Chr(13) & Chr(10)
TempTxt = TempTxt & Chr(13) & Chr(10) & "DETERMINATION: " & Chr(13) & Chr(10)
TempTxt = TempTxt & "I have determined that a violation of your rights did not occur "
TempTxt = TempTxt & "because: The Rights of Recipients of Mental Health Services"
![L1ReasFind] = TempTxt
End Select
If Forms![HiddenAgencySettingsFrm]![Units] Then
![UnitNo] = Me.Parent![UnitNo]
Select Case Me.Parent![UnitNo]
Case 1
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U1Name]
Case 2
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U2Name]
Case 3
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U3Name]
Case 4
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U4Name]
Case 5
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U5Name]
Case 6
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U6Name]
Case 100
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U0Name]
End Select
End If
If Forms![HiddenAgencySettingsFrm]![Units] And _
Not Forms![HiddenAgencySettingsFrm]![UnitsSameNo] Then
Select Case Me.Parent![UnitNo]
Case 1
![GrievID_NoOnly] = Forms![GrvncNmbrngFrm]![U1_G]
![GrievanceID] = Forms![GrvncNmbrngFrm]![U1_Gtxt]
' increment Grievance number for next Grievance
Forms![GrvncNmbrngFrm]![U1_G] = _
CheckForDupsGriev(Forms![GrvncNmbrngFrm]![U1_G] + 1, _
Forms![GrvncNmbrngFrm]![U1_Gmin], _
Forms![GrvncNmbrngFrm]![U1_Gmax], CStr(![UnitAbbriev]))
End Select
Else
![GrievID_NoOnly] = Forms![GrvncNmbrngFrm]![U0_G]
![GrievanceID] = Forms![GrvncNmbrngFrm]![U0_Gtxt]
' increment Grievance number for next Grievance
Forms![GrvncNmbrngFrm]![U0_G] = _
CheckForDupsGriev(Forms![GrvncNmbrngFrm]![U0_G] + 1, _
Forms![GrvncNmbrngFrm]![U0_Gmin], _
Forms![GrvncNmbrngFrm]![U0_Gmax], CStr(![UnitAbbriev]))
End If
If Forms![HiddenAgencySettingsFrm]![Units] Then
![UnitNo] = Me.Parent![UnitNo]
Select Case Me.Parent![UnitNo]
Case 1
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U1Name]
Case 2
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U2Name]
Case 3
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U3Name]
Case 4
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U4Name]
Case 5
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U5Name]
Case 6
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U6Name]
Case 100
![UnitAbbriev] = Forms![HiddenAgencySettingsFrm]![U0Name]
End Select
End If
GoTo ExitSub 'do not close this (Parent) form if ParntForm <> a grievance form
End If
End With
End If
CloseForm:
DoCmd.Close acForm, Me.Parent.Form.Name, acSaveNo 'no need to save this form, it does not modify info
ExitSub:
Exit Sub
Err_Handler:
MsgBox ("Error #" & Err.Number & ": " & Err.Description)
Resume ExitSub
End Sub
The problem is, sometimes it pulls the info from the first record instead of the record of the button clicked on.
Before you ask: yes, it compiles. Access 2016/Office 365, and it is an .accdb, I can't make an executable out of it, it edits tables in the FE.
It all works fantastic otherwise.
If I click on the desired record of the subform, away from buttons (there are no other active controls), and then click on the button it works right 100% of the time.
I would appreciate any troubleshooting ideas. Thank you.