Results 1 to 3 of 3
  1. #1
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020

    Message box to display the name of the textbox that is left blank

    Hello and thank you for taking the time to help with this question!

    I have a group of controls on a form that I have used the Tag property = "Status". I would like the message box to populate the name of the textbox(s)
    that is blank
    within the group tagged "Status" causing the message box to display. Everything works as it currently is but I would like it to be more specific and tell the user what field they actually missed.

    Thank you for any advice you can provide!

    Private Sub btnTotalScore_Click()
    Dim c As Control, nYes As Long, nPartial As Long, nNo As Long, nNA As Long
    nYes = 0
    nPartial = 0
    nNo = 0
    nNA = 0
    For Each c In Me.Controls
        Select Case c.Name
            Case "cboStatus", "cboEmployee", "cboStatus"
            Case Else
        If TypeName(c) = "ComboBox" Then
            If c.Value = "Yes" Then nYes = nYes + 1
            If c.Value = "Partially" Then nPartial = nPartial + 1
            If c.Value = "No" Then nNo = nNo + 1
            If c.Value = "NA" Then nNA = nNA + 1
        End If
    End Select
    Next c
    txtTotalScore = Format((nYes + nPartial * 0.5) / (nYes + nPartial + nNo + nNA), "Percent")
    For Each c In Me.Controls
        If c.Tag = "Status" Then
            If IsNull(c.Value) Then MsgBox ("A categoryhas been left incomplete. Please review and update before continuing.")
        End If
    Next c
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    if isnull(c) then msgbox c.Name & " is reqd"

  3. #3
    jbeets is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2020
    Perfect! Thank you so much! I knew it was going to be something easy! You're the best!

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

Similar Threads

  1. Replies: 2
    Last Post: 05-11-2020, 06:59 AM
  2. Replies: 5
    Last Post: 01-13-2015, 11:57 AM
  3. warning message if field is left blank
    By dimoc in forum Access
    Replies: 3
    Last Post: 04-10-2014, 03:20 PM
  4. Replies: 4
    Last Post: 05-11-2013, 07:51 AM
  5. Replies: 1
    Last Post: 07-25-2011, 09:57 AM

Tags for this Thread

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