Good morning,
So, today's issue is this. I have a form [PatientAllSubs] that has two tabs on it (ONN/PSC and SLC) with subforms on each [PatientSubform] and [SLCSubform] respectively. It is loading the information from the [Patients] table:
txtPatientTitle uses the formula:
Users get to [PatientAllSubs] from my home navigation [HOME] on subform/navigation form of home [PatinetSearchSubform]. They can either search for a patient which carries the information over to [PatientAllSubs] or click a button to enter a new patient.
The code for Open Patient Record is:
There is other code for the search, but that is primary.
The Code for New Patient Entry is just:
So the code is sending the patient ID to the Main form [PatientAllSubs] which is then linked as the Master to the [PatientSubform] and is also the Master for the Child [SLCSubform].
SO, the issue is, when you create a NEW patient by clicking "New Patient Entry" from either the search subform or the NEW PATIENT button the the [PatientAllSubs] form, I am wanting it to update the MAIN form ID, MRN, LastName, FirstName, and DOB fields from the subform to the main form as they are being typed, but it would also have to save the record in order to pull an autokey from the table. Because without updating the MAIN form, if I try to click on the SLC tab or go to a NEW ACTIVITY LOG it won't pull the data with it. Even if I save the record.
Code for the NEW ACTIVITY LOG is:
Code for Save Record:
SOOOO, my question is, how do I get it to, once MRN, LAST, FIRST, and DOB are entered on the subform, auto save the record so it pulls a primary key ID, and in return, update the main form with the info so it can drive the other subform and activity buttons? Because if I add refresh or requery to the save button it pulls my default TEST patient.
Would I need to add code so that when NEW ACTIVITY LOG, SAVE RECORD, or NEW PATIENT is clicked it pulls from the subform to the mainform, THEN opens the items? Would I need to add that to the on click event for the SLC tab?
As always, you are all wonderful.
Just an FYI, coding and databases aren't my job. I am in project management and process improvement but I am putting this together as a stopgap until our tech people can find me a good commercial product outside our typical electronic health record. I code only out of nessecity and haven't for years so I REALLY appreciate the help from this community.
EDIT:
I added:
to my After Update for MRN which IS pulling a record ID to the subform.
So, I added code to my save button:
I don't want to use the OPENFORM because it will open the default test patient. I just need to update the main form info and keep the subform record open.
So, today's issue is this. I have a form [PatientAllSubs] that has two tabs on it (ONN/PSC and SLC) with subforms on each [PatientSubform] and [SLCSubform] respectively. It is loading the information from the [Patients] table:
txtPatientTitle uses the formula:
Code:
=Nz([MRN] & " - " & [LastName] & ", " & [FirstName] & " - " & [DOB],"Untitled")
Users get to [PatientAllSubs] from my home navigation [HOME] on subform/navigation form of home [PatinetSearchSubform]. They can either search for a patient which carries the information over to [PatientAllSubs] or click a button to enter a new patient.
The code for Open Patient Record is:
Code:
Private Sub cmdOpenPatient_Click()
On Error GoTo ErrorHandler
DoCmd.OpenForm "PatientAllSubs", , , "[ID]=" & [lstResults]
Exit Sub
ErrorHandler:
Select Case Err.Number
Case Else
MsgBox "A Patient must be selected. "
End Select
End Sub
There is other code for the search, but that is primary.
The Code for New Patient Entry is just:
Code:
Private Sub cmdPtEntry_Click()
DoCmd.OpenForm "PatientAllSubs"
DoCmd.GoToRecord , , acNewRec
End Sub
So the code is sending the patient ID to the Main form [PatientAllSubs] which is then linked as the Master to the [PatientSubform] and is also the Master for the Child [SLCSubform].
SO, the issue is, when you create a NEW patient by clicking "New Patient Entry" from either the search subform or the NEW PATIENT button the the [PatientAllSubs] form, I am wanting it to update the MAIN form ID, MRN, LastName, FirstName, and DOB fields from the subform to the main form as they are being typed, but it would also have to save the record in order to pull an autokey from the table. Because without updating the MAIN form, if I try to click on the SLC tab or go to a NEW ACTIVITY LOG it won't pull the data with it. Even if I save the record.
Code for the NEW ACTIVITY LOG is:
Code:
Private Sub cmdCallLog_Click()
On Error GoTo ErrorHandler
DoCmd.RunCommand acCmdSaveRecord
Dim strFrmName As String
strFrmName = "ActivityEntryF"
DoCmd.OpenForm strFrmName
With Forms(strFrmName)
.MRNcall = Me.MRN
.LastNamecall = Me.LastName
.FirstNamecall = Me.FirstName
.DOBcall = Me.DOB
.PatientIDcall = Me.ID
End With
Exit Sub
ErrorHandler:
MsgBox "Duplicate MRN Found", vbInformation, "Error"
End Sub
Code for Save Record:
Code:
Private Sub cmdSaveRecord_Click()
On Error GoTo ErrorHandler
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Record Saved", vbInformation, "Save"
Exit Sub
ErrorHandler:
MsgBox "Duplicate MRN Found", vbInformation, "Error"
End Sub
SOOOO, my question is, how do I get it to, once MRN, LAST, FIRST, and DOB are entered on the subform, auto save the record so it pulls a primary key ID, and in return, update the main form with the info so it can drive the other subform and activity buttons? Because if I add refresh or requery to the save button it pulls my default TEST patient.
Would I need to add code so that when NEW ACTIVITY LOG, SAVE RECORD, or NEW PATIENT is clicked it pulls from the subform to the mainform, THEN opens the items? Would I need to add that to the on click event for the SLC tab?
As always, you are all wonderful.
Just an FYI, coding and databases aren't my job. I am in project management and process improvement but I am putting this together as a stopgap until our tech people can find me a good commercial product outside our typical electronic health record. I code only out of nessecity and haven't for years so I REALLY appreciate the help from this community.
EDIT:
I added:
Code:
If Me.Dirty = True Then
Me.Dirty = False
End If
So, I added code to my save button:
Code:
Private Sub cmdSaveRecord_Click()
On Error GoTo ErrorHandler
DoCmd.RunCommand acCmdSaveRecord
Dim strFrmName As String
strFrmName = "PatientAllSubs"
DoCmd.OpenForm strFrmName
With Forms(strFrmName)
Me.MRN = Me!PatientSubform.Form!MRN
Me.LastName = Me!PatientSubform.Form!LastName
Me.FirstName = Me!PatientSubform.Form!FirstName
Me.DOB = Me!PatientSubform.Form!DOB
Me.ID = Me!PatientSubform.Form!ID
End With
MsgBox "Record Saved", vbInformation, "Save"
Exit Sub
ErrorHandler:
MsgBox "Duplicate MRN Found", vbInformation, "Error"
End Sub
I don't want to use the OPENFORM because it will open the default test patient. I just need to update the main form info and keep the subform record open.
Last edited: