How to set a default value on an unbound Auto Complete Box?

I receive tons of question on how to set a default value on an unbound Auto Complete Box, my initial response to this question is to bound it and equate the data binding to the  FirstOrDefault property of a LINQ statement.  Because I really don’t know how to do it on an unbound Auto Complete Box except now.

Instead of looking for a property on how to set the default value of an unbound Auto Complete Box, I change the event on which where to equate the default value of the control, it turns out nice and it worked.  This is Microsoft Access experience 101.

Normally, all my screen properties, controls and data are set on the Created event.  Setting a default value on an unbound Auto Complete box on this event including the Initialize screen event seems to fail but the screen Loaded is a miracle.

In the image below, my unbound Auto Complete Box is the CommissStatus property, by the way, make sure to set the Required property of this control to true.


Once you’ve created the control, insert the sample code snippet below:  My screen name is trnUnitSoldCommission, therefore the code snippet below is the screen Loaded event implementation.

        Private Sub trnUnitSoldCommission_Loaded(succeeded As Boolean)
            If Me.CommissionStatus Is Nothing Then
                Me.CommissionStatus = "REQUESTED"
            End If
        End Sub

Thats it!

If you find this blog helpful, you can make the donation by clicking the Paypal button below.


4 thoughts on “How to set a default value on an unbound Auto Complete Box?

  1. Hi Glenn. is auto complete box almost similar to combo box in Access? I wonder why LS dev did not get idea and learn from Access intrinsic data bound controls and extend it the LS way. Life could be much easier if that is the case, and also the addition of native reporting.

    1. I think its a technological issue, the memory management of an application that rides with HTML through a browser is totally different from a control that uses the full power of the hardware using the operating system. For example in an auto complete box, the data that is extracted in the database has to be processed and prepared at the server layer before it get sent to the client through HTML, in effect, a simple default value setting at the client side is tricky.

  2. Hi Glenn,

    Thanks for the nice site, I’m also using Access here for my apps. I am currently exploring Lightswitch and so far I am liking it, can you please recommend a reporting component for LS 2012 or maybe extend some pointers for an Access Dev to LS.

    Thank you in advance.

    Kind regards,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s