Consulting

Results 1 to 4 of 4

Thread: Problem to set the standard value in a combobox in a form

  1. #1
    VBAX Regular
    Joined
    Jan 2016
    Posts
    35
    Location

    Problem to set the standard value in a combobox in a form

    Hello,


    I’ve got a form with a combobox named “Tijdvak”
    The recordsource is a table called “tblTijdvak” , with autonumbering ´Tijdvak_Id´ , and a short textfield with the name
    “Tijdvak”.

    In the table “tblTijdvak” is the id. nr 78 , and the name of the textfield is wk26.

    I put in the form, in the combobox field “Tijdvak” the next standardvalue I quote, ="wk"&(Format(Date();"ww"))
    I hoped that the outcome was simple wk26, that is the current week of the year.
    But there nothing to see in my form in the combobox “Tijdvak” when I open this form.

    To check if my expression was correct in the immediate window I typed:
    ?"wk"&(Format(Date();"ww"))
    Now it works fine. The result was wk26

    How can I get the same result in my combobox in the form?

    Thanks in advance.
    TonC

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    I do not know what version of Access you are using, but in all versions up to 2007 the controlling characteristic for a combo box (or other field) is the
    Default Value
    So try using your expression in that control on the Combo Box's "Data Tab" in design mode.

  3. #3
    Note: The default value must be a valid for the bound coulmn (should be the primary key). If the bound column is hidden (column witdth = 0), you still must set the default based on the bound column. Not what is displayed to the user.

    In your example, the bound column should be Tijdvak_Id. This a is an auto number. The default value must be a integer. An autonumber will never equal ="wk"&(Format(Date();"ww")).
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  4. #4
    VBAX Regular
    Joined
    Jan 2016
    Posts
    35
    Location
    Hello HiTechCoach,

    Yes, you are right. Its stupid from me to put a string in a autonummer field. Is there perhaps a solution?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •