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.

b1

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.

Advertisements
About

Software developer living in the Philippines.

Posted in Lightswitch
4 comments on “How to set a default value on an unbound Auto Complete Box?
  1. ronnie valero says:

    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.

    • hgminerva says:

      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. Alex says:

    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,
    Alexis

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Author

Harold Glenn P. Minerva
Software Developer / Tech Enthusiast
Living in the Philippines

View Harold Glenn Minerva's profile on LinkedIn

Instagram

Software Engineer - Seasonal and Range Trading Software. Magenta Trader is a powerful stock market visualization software that increases your probability of trading success.

Software Architect and Founder - Easyfis.com is a multi-tenant cloud-based Software-as-a-Service (SaaS) business app that caters to micro, small and medium trading businesses.

CTO and Co-Founder - We give your company the leverage by providing innovative software solutions products such as Point-of-Sales (POS), Financial Information System (FMIS), Payroll and DTR (HRIS), and many more.

%d bloggers like this: