Public Sub PrescriptionLoad()
Dim fPre As Form
On Error GoTo PL_Err
DoCmd.OpenForm "ChartPrescription", , , , acFormAdd
Set fPre = Forms!ChartPrescription
fPre.Rx1 = DLookup("Rx1", "CHANNotesTblRxFrequent")
fPre.Rx2 = DLookup("Rx2", "CHANNotesTblRxFrequent")
fPre.Rx3 = DLookup("Rx3", "CHANNotesTblRxFrequent")
fPre.Rx4 = DLookup("Rx4", "CHANNotesTblRxFrequent")
fPre.Rx5 = DLookup("Rx5", "CHANNotesTblRxFrequent")
fPre.Rx6 = DLookup("Rx6", "CHANNotesTblRxFrequent")
fPre.Rx7 = DLookup("Rx7", "CHANNotesTblRxFrequent")
fPre.Rx8 = DLookup("Rx8", "CHANNotesTblRxFrequent")
fPre.Rx9 = DLookup("Rx9", "CHANNotesTblRxFrequent")
fPre.Rx10 = DLookup("Rx10", "CHANNotesTblRxFrequent")
'_____________________________________________________
Forms!ChartPrescription.nPName = Forms!ChartMain.PName
Forms!ChartPrescription.nPTel = Forms!ChartMain.nPTel
Forms!ChartPrescription.nPID = Forms!ChartMain.nPID
Forms!ChartPrescription.nType = "ATx"
Forms!ChartPrescription.nDate = Date
Forms!ChartPrescription.DOB = Forms!ChartMain.nDOB
Forms!ChartPrescription.Allergy = Forms!ChartMain.Allergy
Forms!ChartPrescription.RxComments = Forms!ChartMain!RxComments
Forms!ChartPrescription.PharmTel = Forms!ChartMain!RxComments
' Create Pharmacy Location String Strip off Telephone and message
Dim P As String
Dim strCount As Integer
Dim PFinal As String
P = Forms!ChartMain!Pharm
strCount = InStr(1, P, Chr(13) & Chr(10))
PFinal = Left(P, strCount - 1)
'________________________________________________________
' -------Separate out Pharm Telephone from ChartMain!Pharm
Dim c As Integer ' there are 2 vbcrlf's in Pharm to get to Pharm Tel T1
Dim c1 As Integer ' counter for second vbCrLF (Chr(13) and Chr(10) T2
Dim r As String ' all of Pharm string TestStr
Dim R1 As String ' Length of Pharm String T3
Dim R2 As String ' PharmTel stripped out. T4
Dim Ph As String
Dim Ph1 As String
Dim Ph2 As String 'Pharm Name
Dim Ph3 As String
Dim Ph4 As String
Dim Ph5 As String 'PharmTel and Comments
Dim Ph6 As String
Dim PT As String
Dim PTF As String
Dim marker As String
Dim marker1 As String
Ph = [Forms]![ChartMain]![Pharm] ' this strips out Phone# from Pharmacy info.
Ph1 = InStr(1, [Ph], Chr(13) & Chr(10))
Ph2 = Left([Ph], [Ph1] - 1) ' Pharmacy Name
r = Forms!ChartMain!Pharm
marker = Chr(13) & Chr(10)
c = InStr(1, r, marker) 'count to first Linefeed
If c > 0 Then
c1 = InStr(c + 1, r, marker) 'count to second Linefeed
Ph3 = c1 'count to Final Pharm Name only stripped out.
End If
R1 = Len(r) 'Length of Original Pharm Name on ChartMain
Ph4 = R1 'test field
R2 = Right(r, R1 - c1 - 1)
Ph5 = R2 'test field
Ph6 = Mid(Ph, Ph1 + 1, c1 - c)
fPre.Pharm = Ph2 & " - " & Ph6
fPre.PharmTel = R2
' From PharmTel break down string to only telephone number
marker = "Chr(13) & Chr(10)"
marker1 = "//"
PT = Forms!ChartPrescription!PharmTel
strCount = InStr(1, PT, marker1)
If strCount > 0 Then
strCount = InStr(1, PT, marker1)
End If
PTF = Left(PT, strCount - 1)
'Forms!ChartPrescription!nNote = "Rx CALLED: " & PFinal & " - " & PTF 'RX Called: Pharm (w/o City/Street) - PharmTel
Forms!ChartPrescription!nNote = "Rx CALLED: " & Ph6 & " - " & PTF
DoCmd.GoToControl "aa"
PL_Exit:
Exit Sub
PL_Err:
DoCmd.Close acForm, "ChartPrescription"
MsgBox "Please check or update Pharmacy."
Resume PL_Exit
End Sub