Sub Controlli ()
	window.event.returnValue = False
	If frm1.ADAl.value <> "" Then
		If frm1.AAl.value = "" Then
			msgbox "Inserire Anno Al", vbcritical, "Inserire valore"
			frm1.AAl.focus()
			Exit Sub
		End If
		If frm1.ADal.value < 1000 Or frm1.ADal.value > 2499 Then
			msgbox "Anno inizio periodo errato", vbcritical, "Valore errato"
			frm1.ADal.focus()
			Exit Sub
		End If
		If frm1.ADal.value > frm1.AAl.value Then
			msgbox "L'anno di fine periodo deve esse maggiore dell'anno di inizio periodo", vbcritical, "Valore errato"
			frm1.AAl.focus()
			Exit Sub
		End If
		If frm1.anno.value <> "" Then
			msgbox "Non selezionare il singolo anno se è stato inserito il periodo dal - al ", vbcritical, "Valore errato"
			frm1.anno.focus()
			Exit Sub
		End If
		If Not IsNumeric(frm1.ADal.value) Then
			msgbox "Inserire anno di inizio periodo nel formato con 4 cifre", vbcritical, "Valore errato"
			frm1.ADal.focus()
			Exit Sub
		End If
	End If
	If frm1.AAl.value <> "" Then
		If frm1.ADal.value = "" Then
			msgbox "Inserire Anno Dal", vbcritical, "Inserire valore"
			frm1.ADal.focus()
			Exit Sub
		End If
		If Not IsNumeric(frm1.AAl.value) Then
			msgbox "Inserire anno di fine periodo nel formato con 4 cifre", vbcritical, "Valore errato"
			frm1.AAl.focus()
			Exit Sub
		End If
		If frm1.AAl.value < 1000 Or frm1.AAl.value > 2499 Then
			msgbox "Anno fine periodo errato", vbcritical, "Valore errato"
			frm1.ADal.focus()
			Exit Sub
		End If
	End If
	If frm1.Cod.value <> "" Then
		If frm1.Aut.value <> "" Or frm1.Tit.value <> "" Or frm1.anno.value <> "" Or frm1.regione.value <> "" Then
			msgbox "Non inserire altre selezioni insieme al codice opera", vbcritical, "Valore errato"
			frm1.Cod.focus()
			Exit Sub
		End If
	End If
	'ho passato tutti i controlli
	window.event.returnValue = True
End Sub
