I am trying to come up with the correct code for the following scenario. I have a pop-up form with that opens with the PhnIndex number is click on another form. On the pop-up form I have a command button to view change history. When click it will open the form based on the PhnIndex field of the pop-up form. I have an issue if the record does not have a change history. When the button is click it brings up a blank form.
What I would like to do is to have a message box display "This station does not have any change history".
The table where the changes are stored is named audManagedIP. The PhnIndex field is a number field and the only constant in the record since it is the primary key in the main table where all records are stored.
This is the code I tried but the blank form still pops up
Code:
Private Sub Command54_Click()If Nz(DLookup("PhnIndex", "audManagedIP"), "") = "" Then
MsgBox "There is no change history for this station."
Exit Sub
Else
DoCmd.OpenForm "frm_auditviewcare", , , "[phnindex] =" & Forms!frm_care_edit.PhnIndex
DoCmd.Close acForm, "frm_care_edit", acSaveYes
End If
End Sub
Any help on this would be greatly appreciated!!!