Hi, i have written code for report open such that the person is prompted to enter an ID which will then bring up that ID's corresponding report.That part is working fine, however I want a msgbox to display if this ID does not exist in the records. The following code is what i have, any help would be appreciated!!
Private Sub Report_Open(Cancel As Integer)
Dim strID As String
Dim strWhere As String
strID = InputBox("Please enter the patients hospital ID.")
strWhere = "[general_info.HospitalNumber] = " & "'" & strID & "'"
strDocName = "Home_Oxygen_Report"
If strWhere = "" Then
If MsgBox("Invalid Hospital ID. Click OK to try another ID or Cancel.", vbOKCancel) = vbOK Then
strID = InputBox("Please enter the patients hospital ID.")
Else
DoCmd.Close
End If
Else
DoCmd.OpenReport strDocName, acPreview, , strWhere
End If
End Sub
Thanks
Tania![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Private Sub Report_Open(Cancel As Integer)
Dim strID As String
Dim strWhere As String
strID = InputBox("Please enter the patients hospital ID.")
strWhere = "[general_info.HospitalNumber] = " & "'" & strID & "'"
strDocName = "Home_Oxygen_Report"
If strWhere = "" Then
If MsgBox("Invalid Hospital ID. Click OK to try another ID or Cancel.", vbOKCancel) = vbOK Then
strID = InputBox("Please enter the patients hospital ID.")
Else
DoCmd.Close
End If
Else
DoCmd.OpenReport strDocName, acPreview, , strWhere
End If
End Sub
Thanks
Tania