?
Solved

Better way of writing the code

Posted on 2016-10-04
4
Medium Priority
?
49 Views
Last Modified: 2016-10-04
Hello,

  Is there a better of writing this code rather than repetition:

    If Me.BtnEditRecordHotelID.Enabled = True Then
                    ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")
                Else
                    ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")
                    Exit Sub
                End If

Open in new window


Cheers
0
Comment
Question by:RIAS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
Paweł earned 2000 total points
ID: 41827777
since it looks as if you're formating is the same why not pull it out of the if and just exit the sub if the Me.BtnEditRecordHotelID.Enable is false


ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")

 If Me.BtnEditRecordHotelID.Enabled = false
     Exit Sub
End If
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 41827779
   ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")

  If Me.BtnEditRecordHotelID.Enabled = False Then
        Exit Sub
End If

Open in new window

1
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 41827783
Hi,

maybe
ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")
If Me.BtnEditRecordHotelID.Enabled = False Then Exit Sub

Open in new window

Regards
1
 

Author Comment

by:RIAS
ID: 41827785
Cheers!
0

Featured Post

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question