Question Help to trap error

josephbupe

Registered User.
Local time
Today, 13:45
Joined
Jan 31, 2008
Messages
247
Hi,

Please, I need help to create an error trap in the following code which is behind a LogIn button. The txtSignIn is a combo box to select a user, error appears when user clicks a a LogIn button without selecting their name.

Code:
DoCmd.OpenForm "frmUserInfo", , , "[UserName] = '" & Me.txtSignIn & "'", , acHidden
    DoCmd.Close acForm, "frmSignIn"
    DoCmd.OpenForm "frmMainMenu"
    DoCmd.OpenForm "frmMessageCount"

I will appreciate.

Joseph
 
Last edited:
air code...

Code:
if nz([YourLoginField]) = "" then
  msgbox"you must select your user name first"
  exit sub
end if
 
Hi ghudson,

I tried your code but no success. The sample am working on can be found on the following link: http://www.utteraccess.com/forum/Instant-Messenger-t1169381.html

As indicated in my previews post, the error appears when you click the LogIn button without having selected User name.

Joseph

Please tell me that you did change the ([YourLoginField]) to the name of your field when you tried my code? :confused:

I just opened the sample from your link and I put my code in the onclick event of the cmdSignIn button and it work perfectly when I changed the [YourLoginField] to [txtSignIn].

Here is the code...

Code:
Private Sub cmdSignIn_Click()

'//\\' CLOSE/OPEN FORM(S)
    If Nz([[B][SIZE="4"][COLOR="Blue"]txtSignIn[/COLOR][/SIZE][/B]]) = "" Then
      MsgBox "you must select your user name first"
      Exit Sub
    End If
    
    DoCmd.OpenForm "frmUserInfo", , , "[UserName] = '" & Me.txtSignIn & "'", , acHidden
    DoCmd.Close acForm, "frmSignIn"
    DoCmd.OpenForm "frmMainMenu"
    DoCmd.OpenForm "frmMessageCount"

End Sub
 

Users who are viewing this thread

Back
Top Bottom