Good Practice or Bad?

  • Thread starter Thread starter Jerry Stoner
  • Start date Start date
J

Jerry Stoner

Guest
A developer where I am contracted to constructs his If statements like this:
If Day(Now()) <> 1 Then DoCmd.OpenQuery "qry_06c_Get_CurMon_Rebates"

Instead of like this:
If Day(Now()) <> 1 Then
DoCmd.OpenQuery "qry_06c_Get_CurMon_Rebates"
End If

All on one line and no end if needed. I didn't even know that would work.
Is this good or bad practice from a coding standpoint? Any Pitfalls?
Thanks
 
One line works just fine, I like the END IF version because I find it easier to read, unless it is a short IF.
IF MyFlag then A=12 ' as a short example
 
Guess you do learn something every day! Thanks
 
I sometimes use single line IFs when I do not need an Else. Never had a problem with it.
 
I use the multi-line syntax (probably a left over from my COBOL days) because I find it easier to read. Also, if you have a lot of If's, someone might think that the single line If was part of some other If if they didn't read it closely.
 

Users who are viewing this thread

Back
Top Bottom