Paul Cooke
Registered User.
- Local time
- Today, 07:34
- Joined
- Oct 12, 2001
- Messages
- 288
Could someone please advise me how to hide a form if a text control on it is null?
At the moment I have the following code
	
	
	
		
At the moment the Vaccination form opens 'on top' but I want this form to be hidden if the Email address field is empty. I have tried loads of different bits of code after :-
	
	
	
		
but nothing seems to work.
I am not sure if this would be better off in the Onload event but am resisting doing that as it would mess up the flow of the message boxes
Is there anyway to resolve this in the Oncurrent event?
many thanks
Paul
 At the moment I have the following code
		Code:
	
	
	Private Sub Form_Current()
'Looks up current Patient Name and DOB to show on forms
Dim strFirstName As String
Dim strSurname As String
Dim strDob As String
    strFirstName = Forms!FindPatientVaccination.lstPatients.Column(1)
    strSurname = Forms!FindPatientVaccination.lstPatients.Column(2)
    strDob = Forms!FindPatientVaccination.lstPatients.Column(3)
    Me.txtPatientName = strFirstName & " " & strSurname & " - " & strDob
'Looks up patient record and populates relevant controls on vaccination form
If Me.OpenArgs = "Vaccination" Then
    Me.txtPatientID = Forms!FindPatientVaccination.lstPatients
    lngPatientID = Forms!FindPatientVaccination.lstPatients
    Me.txtPatientFirstName = DLookup("PatientFirstName", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtPatientSurname = DLookup("PatientSurname", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtHomeAddressLine1 = DLookup("HomeAddressLine1", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtHomeAddressLine2 = DLookup("HomeAddressLine2", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.cboUkCityTownVillageID = DLookup("UkCityTownVillageID", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.cboUKCountyID = DLookup("UkCountyID", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtHomeAddressPostCode = DLookup("HomeAddressPostCode", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtEmailAddress = DLookup("EmailAddress", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtHomeTelephoneNumber = DLookup("HomeTelephoneNumber", "PatientDetails", "PatientID= " & lngPatientID & "")
    Me.txtTelephoneNumberMobile = DLookup("TelephoneNumberMobile", "PatientDetails", "PatientID= " & lngPatientID & "")
    
    
End If
'Checks to see if a new record has been selected and looks up new number
If Me.NewRecord = True Then
    lngTrNum = DLookup("NextVaccinationNumber", "ReferenceNumbers")
    strTrPrefix = DLookup("VaccinationPrefix", "ReferenceNumbers")
    Me.txtVaccinationNumber = strTrPrefix & lngTrNum
End If
If IsNull(Me.txtPatientID) Then
    Me.txtPatientID = Forms!FindPatientVaccination.lstPatients
End If
'check to see if patient details are complete
If IsNull(Me.txtEmailAddress) = True Then
    Beep
    MsgResponse = MsgBox("There is no email address on record for this patient, please update the missing information before entering the vaccination details." & vbCrLf & vbCrLf _
    & "It is important to ensure we have an email address so we can inform the patient when thier vaccines are due for a booster or are about to expire." & vbCrLf & vbCrLf _
    & "Does the patient have an email address?", vbYesNo, "Information Needed")
If MsgResponse = vbYes Then
    DoCmd.OpenForm "FindPatientAmend", , , , , , "VaccinationAmend"
    MsgBox "Please select the correct patient and complete the missing information in the Fields highlighted in red.", vbInformation, "Information"
    End If
End If
End SubAt the moment the Vaccination form opens 'on top' but I want this form to be hidden if the Email address field is empty. I have tried loads of different bits of code after :-
		Code:
	
	
	If IsNull(Me.txtEmailAddress) = True Thenbut nothing seems to work.
I am not sure if this would be better off in the Onload event but am resisting doing that as it would mess up the flow of the message boxes
Is there anyway to resolve this in the Oncurrent event?
many thanks
Paul
 
	 
 
		 
 
		