private void button3_Click(object sender, EventArgs e) { Login login = new Login(); login.ShowDialog(); //add code here //if we type a wrong pwd but close the dialog, we can still log in the sales report if (Login.logincorrect == true) { SalesApp salesapp = new SalesApp(); salesapp.Show(); Login.logincorrect = false; } }