I am setting up a database containing patient information. Right now, users can navigate to a particular patients information (Patient Home Page) using a search/confirm form. The Home Page has links to other forms with additional patient information. The code works when users search for a patient that was put in from the beginning (aka the "patients" I put in as test people at the beginning will show up and the code behaves as it is supposed to). However, when I try to add a new patient, the confirmation form will no longer work. The new record is created in the patient list table and the search form will find the new patient, but when I click on the continue button on the confirmation form, the Patient Home Page pulls up as a new (blank) record. The code only breaks with new patients.
I am also having an issue creating a new record in the "Equipment Log" form when I add a new patient to the home page form. I have a 1-to-1 relationship between the equipment log and patient home page, with pt ID being the primary key for both tables. When I add a new patient through the "pt home page", I need to create a linked record in the equipment log that is connected via the pt ID. So far, I have tried code similar to that found below and other similar things, but nothing seems to work.
Code for the search and confirmation pages are below, as well as part of the code for the patient home page (although I don't know that that code is very useful). Any help is appreciated, I've been stuck on this for awhile.
Patient Search Page:
Private Sub Patient_Search_Click()
On Error GoTo Patient_Search_Click_Err
DoCmd.OpenForm "Confirmation", acNormal, "", "", acReadOnly, acNormal
Patient_Search_Click_Exit:
Exit Sub
Patient_Search_Click_Err:
MsgBox Error$
Resume Patient_Search_Click_Exit
End Sub
Private Sub add_new_Click()
On Error GoTo add_new_Click_Err
' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
' <UserInterfaceMacro For="Patient Search" Event="OnClick" xmlns="http://schemas.microsoft.com/office/accessservices/2009/11/application" xmlns:a="http://schemas.microsoft.com/office/accessserv
' _AXL:ices/2009/11/forms"><Statements><Action Name="OpenForm"><Argument Name="FormName">Confirmation</Argument><Argument Name="DataMode">Read Only</Argument></Action></Statements></UserInterfaceMacro>
DoCmd.OpenForm "Patient Home Page"
DoCmd.GoToRecord , , acNewRec
add_new_Click_Exit:
Exit Sub
add_new_Click_Err:
MsgBox Error$
Resume add_new_Click_Exit
End Sub
Patient Confirmation Page (*Note: I edited this and added a breakpoint at the debug.print. When I run the command nothing prints and now nothing will open)
Private Sub confirm_Click()
testid = [Patient List_ID]
Debug.Print
DoCmd.OpenForm "Patient Home Page", acNormal, "", "[ID]=" & "'" & [Patient List_ID] & "'"
End Sub
Patient Home Page:
Private Sub Form_Current()
If Me.NewRecord Then
Me.equipment_log.Visible = False
Me.echos.Visible = False
Me.open_logs.Visible = False
Me.openadvisory.Visible = False
Me.save.Visible = True
Me.edit.Visible = False
Me.cancelupdate.Visible = True
Last_Name.Locked = False
First_Name.Locked = False
Middle_name.Locked = False
Device.Locked = False
Patient_List_ID.Locked = False
MRN.Locked = False
DOB.Locked = False
Implant_Date.Locked = False
Transplant_Goal.Locked = False
Status.Locked = False
Caregiver.Locked = False
Address.Locked = False
City.Locked = False
State.Locked = False
Zipcode.Locked = False
Phone_1.Locked = False
Phone_2.Locked = False
Phone_3.Locked = False
Else
Me.equipment_log.Visible = True
Me.echos.Visible = True
Me.open_logs.Visible = True
Me.openadvisory.Visible = True
Me.save.Visible = False
Me.edit.Visible = True
Me.cancelupdate.Visible = False
Last_Name.Locked = True
First_Name.Locked = True
Middle_name.Locked = True
Device.Locked = True
Patient_List_ID.Locked = True
MRN.Locked = True
DOB.Locked = True
Implant_Date.Locked = True
Transplant_Goal.Locked = True
Status.Locked = True
Caregiver.Locked = True
Address.Locked = True
City.Locked = True
State.Locked = True
Zipcode.Locked = True
Phone_1.Locked = True
Phone_2.Locked = True
Phone_3.Locked = True
End If
End Sub
Create new record in equipment log from new entry in patient list (inside of if statement for create new record)
Dim crit As String
crit = [Patient List_ID]
DoCmd.OpenForm "Patient Equipment Log"
DoCmd.GoToRecord , , acNewRec
Forms![Patient Equipment Log]![Patient Equipment.ID] = crit