Number format problems in an unbound list box

Posted on 2006-05-01
Last Modified: 2008-03-06
Hi folks,

I have a main form which provides a way to select a particular item by double-clicking on it in a list box. The user can select how they want the list sorted by means of an option group; after update, the following code (partial) is executed:

 Select Case ![SearchType]
         Case 1 'Search by Company
          ![lstChoices].RowSource = ""
          ![lstChoices].ColumnCount = 7
          ![lstChoices].ColumnWidths = " 0 in; 1.4 in; 0.7 in; 0.75 in; 2 in; .8 in; .5 in"
          ![lstChoices].BoundColumn = 2
          ![lstChoices].Left = 375.048
          ![lstChoices].Width = 8900.05
          ![lstChoices].RowSource = "qryLeadSortByCompany"
      ---- etc.

Included in the list is a date field and a quantity field.  I have made sure that the formatting for quantity is set to standard with 0 decimal places all the way back to the table as well as in the query, and I want the date to be formatted as Short Date for the purposes of the list box (the table formats it as General Date).

When the list box executes with the query, I can't get the quantity field to obey the formatting, and curiously, with three of the four queries, Short Date holds, but reverts to General Date in the fourth query.

Does anyone know what's going on and how I can make this work?


Charlie T.

Question by:charlietou
    LVL 38

    Accepted Solution

    Are you using the Format(MyDateFld,"Short Date") or Format(MyNumFld,"##0") in your queries.  

    The Format command returns a string regardless of the original data type.   You would need to wrap it with something like CDate(Format(MyDateFld,"Short Date")) after formatting it.
    LVL 3

    Author Comment

    Uh, no ...

    I was just using the Properties / Format field in the query editor window.

    You're saying the format / CDate functions should be part of the field definition?

    So then what would the syntax be for formatting numbers with a comma and no decimal places?

    LVL 38

    Expert Comment

    by:Jim P.
    Glad to be of assistance. May all your days get brighter and brighter.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now