If Trim(txtCognome) = "" Or Trim(txtNome = "") Then MsgBox "Inserisci i dati mancanti", vbExclamation

oppure


ok1 = 0: ok2 = 0
If Trim(txtCognome) = "" Then ok1 = ok1 + 1
If Trim(txtNome = "") = "" Then ok2 = ok2 + 1
If ok1 + ok2 = 2 Then MsgBox "dati mancanti in txtCognome e txtNome": Exit Sub
If ok1 = 1 Then MsgBox "dati mancanti in txtCognome": Exit Sub
If ok2 = 1 Then MsgBox "dati mancanti in txtNome": Exit Sub