Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make the following code simpler with Arrays
    text
    copied!<p>This is by no means essential, but I would like to find out how to create more efficient code, and i'm sure this is far from efficient!</p> <p>On the form disabled fields values are cleared before the form is saved.</p> <p>The below code send a message to the user to inform them that they may lose some data if they leave a checkbox unchecked. In the context of the form it all makes sense, i would just like to know a simpler methodology, i'm sure i could use an array somewhere but cant quite figure it out.</p> <pre><code>Dim couldLoseData As Boolean Dim msgStr As String couldLoseData = False If (Me.chkInvSent = False) And (Not IsNull(Me.invoicedDate)) Then couldLoseData = True msgStr = "Invoice Sent" End If If (Me.chkFeePaid = False) And (Not IsNull(Me.datePaid)) Then couldLoseData = True If msgStr = "" Then msgStr = "Claim Fee Paid" Else msgStr = msgStr &amp; " / Claim Fee Paid" End If End If If (Me.chkFeeLodged = False) And (Not IsNull(Me.lodgedDate)) Then couldLoseData = True If msgStr = "" Then msgStr = "Fee Lodged" Else msgStr = msgStr &amp; " / Fee Lodged" End If End If If couldLoseData = True Then If MsgBox("You will lose data in the following areas as the relevant checkboxes are unticked." &amp; vbNewLine &amp; vbNewLine &amp; _ msgStr &amp; vbNewLine &amp; vbNewLine &amp; "Do you wish to continue?", vbYesNo, dbNameOf) = vbNo Then Cancel = True End If Else ' ' ' ' Procedure that gets carried out here End If </code></pre> <p>No biggie but if any one could offer me a simpler solution it would be appreciated.</p> <p>Cheers</p> <p>Noel</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload