Results 1 to 3 of 3

Code for If, Then, Else with message

  1. #1
    Marcia's Avatar
    Marcia is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2019
    Posts
    37

    Code for If, Then, Else with message

    Another question please. In the following code, I would like to add a condition, "If [Status]="DELINQUENT", [Remarks] should not be left blank" but I am really at a loss on how to insert it.


    Code:
    Private Sub Remarks_Exit(Cancel As Integer)
      If [Status]="DELINQUENT", Then [Remarks] Is Not Null (there should be a message "Reason" if the control button is blank
      DoCmd.RefreshRecord
      DoCmd.GoToControl "NameOfOwner"
      DoCmd.GoToRecord
    End If
    End Sub
    Thank you.

  2. #2
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    2,085
    Maybe this:
    Code:
    Private Sub Remarks_Exit(Cancel As Integer)
        If [Status]="DELINQUENT" Then 
            if isnull(Remarks) then
               msgbox "Remarks cannot be blank if status is DELINQUENT.",vbokonly+vbInformation,"  Check Input  "
               cancel = true
               exit sub
           end if
       end if 
       DoCmd.RefreshRecord
       DoCmd.GoToControl "NameOfOwner"
       DoCmd.GoToRecord
    End Sub
    
    Last edited by davegri; 08-27-2019 at 11:58 AM. Reason: syntax

  3. #3
    Marcia's Avatar
    Marcia is offline Advanced Beginner
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2019
    Posts
    37
    Perfect! Thank you Davegri. The gospel verse, "Be a blessing to others" is alive in this and MSOfficeForums.

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

Similar Threads

  1. Replies: 9
    Last Post: 08-06-2018, 07:18 AM
  2. Code for Message Box
    By Alex Motilal in forum Programming
    Replies: 4
    Last Post: 03-28-2018, 04:07 AM
  3. Get Write Conflict message due to my VBA code
    By mcomp72 in forum Programming
    Replies: 1
    Last Post: 11-07-2017, 01:41 AM
  4. Error message code
    By FJM in forum Access
    Replies: 11
    Last Post: 09-09-2013, 04:42 AM
  5. Alert Message Code Problem
    By 10 Gauge in forum Forms
    Replies: 1
    Last Post: 03-15-2011, 12:17 PM

Posting Permissions

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