Results 1 to 4 of 4
  1. #1
    tomneedshelp is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    5

    Coding for message box


    Private Sub username_Click()
    Dim TextPart As String
    Dim NumberPart As String

    If IsNull(Forename) Then Exit Sub
    If IsNull(Surname) Then Exit Sub
    If Len(Forename) < 3 Then Exit Sub
    If Len(Surname) < 2 Then Exit Sub
    TextPart = Left(Forename, 3) + Left(Surname, 2)
    NumberPart = DMax("Right(UserName,4)", "tblmembers")
    NumberPart = NumberPart + 1
    username = TextPart & NumberPart
    End Sub

    This is the coding i have so far on my form, but i need to display a message box if the user is too youung or has not completed the form. can someone tell me how to layout the coding for a message box.
    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,422
    Try:
    Code:
    If IsNull(Forename) Or IsNull(Surname) Or Len(Forename) < 3 Or Len(Surname) < 2 Then
       MsgBox "Form not complete."
    ElseIf Age < 21 Then
       MsgBox "Too young"
    Else
       TextPart = Left(Forename, 3) + Left(Surname, 2)
       NumberPart = DMax("Right(UserName,4)", "tblmembers")
       NumberPart = NumberPart + 1
       username = TextPart & NumberPart
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    The real question is why would my name exit sub.


    sincerely - Xi Xu

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,422
    Good question. Remember the guy with surname O and had to change to Oh because of Social Security or something like that?

    Maybe should just check for empty string. The following will handle Null or empty string.

    If Forename & "" = "" Or Surname & "" = "" Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Please help with VB coding
    By winterh in forum Import/Export Data
    Replies: 11
    Last Post: 03-19-2012, 06:05 PM
  2. Need help in VBA coding
    By Kcgp in forum Programming
    Replies: 6
    Last Post: 02-01-2012, 11:22 PM
  3. Date coding
    By shralpy in forum Programming
    Replies: 7
    Last Post: 11-25-2011, 04:29 PM
  4. Coding newbie
    By Phoenyxsgirl in forum Programming
    Replies: 2
    Last Post: 10-13-2011, 08:37 AM
  5. Bar-Coding
    By texasprincess7 in forum Access
    Replies: 1
    Last Post: 02-12-2009, 10:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums