OK, sorry it took me a bit to get back to you, I was a busy this morning at work. What I'm going to do is explain how I would handle this in a web database and you can adapt it to your circumstances. Since I don't know much about your application this will be easier than trying to explain to you how to correct what you've got going on your end.
First, this example assumes the following;
1) A table named tblLogin with the fields;
2) A form named frmLogin with the following Controls
- txtUserName (text box)
- txtPassword (text box)
- cmdLogin (command button)
3) A form named frmSplashScreen that you want to open if the login attempt is successful.
This method uses three macros;
1) A table level data macro to check if a record exists with the User Name and Password supplied by the login form.
2) An embedded macro in the Click event of the command button on the login form to run the data macro.
3) An embedded macro in the Load event of the login form to initialize certain settings.
First, the data macro for tblLogin. This macro uses parameters for the UserName and Password values. This macro sets a ReturnVar (return variable) that is then used by the embedded macro in the form.
Note: You cannot supply the UserName and Password values directly in this macro, you simply create the parameters. The values are supplied later when the data macro is run by the embedded macro in the form.
The data macro looks like;
Next, the embedded macro in the Click event of the command button on the form. This macro uses RunDataMacro to run the table level data macro. The values for the parameters come from the text boxes on this form. If the ReturnVar supplied by the data macro is True, then a matching record was found so we close the current form and open the Splash Screen. If the ReturnVar is False then no matching record was found so a message box is displayed and the form controls are disabled. This macro also increments a counter to track login attempts. This macro looks like;
Last, the embedded macro in the Load event of the login form. This macro initializes the login counter to zero and makes sure that the form controls are enabled in case they were disabled on a previous attempt. This macro looks like;