Results 1 to 2 of 2
  1. #1
    lsmcal1984 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Oct 2013
    Posts
    5

    Default value on an unbound combo box

    Dear all,



    I have a combobox that looks up names in tblAgency. This combobox is disabled unless a checkbox for agency is selected.

    When I add a new record, I want the combobox to default to Record 4 in tblAgency. However, the form is based on tblNames (as it uses a subform in datasheet view). The

    The row source code is.

    Code:
    SELECT [tblAgency].[AgencyID], [tblAgency].[AgencyName] FROM tblAgency ORDER BY [AgencyName];
    I have set the default value as =[tblAgency].[AgencyName](4).

    However, it stills appears blank when I add a new record.

    Finally, if possible, I'd like the combobox to reset to the default value when the checkbox is unticked.

    Many thanks!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    When you create a new record you want your combobox to default to ID 4.

    Place the following in the form's current event

    Code:
    If Me.NewRecord = True Then
    Me.ComboBoxName.Column(0) = 4
    End If
    If the checkbox is unticked you want your combobox to default to ID 4. Assuming you do not have the default value of your yes/no field assigned as "Null", this should work by placing it in the afterupdate event of your checkbox.

    Code:
    If Me.CheckBoxName.Value = 0 Then
    Me.ComboBoxName.Column(0) = 4
    End If
    I have not tested this code. Based on your select query, your ID column should be index 0 when looking at it from this VBA perspective.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-05-2013, 09:07 PM
  2. Replies: 1
    Last Post: 04-10-2013, 12:47 PM
  3. Unbound Combo Box to filter form
    By Firefighter22 in forum Forms
    Replies: 4
    Last Post: 08-31-2011, 03:39 PM
  4. using unbound combo box to filter report
    By jlclark4 in forum Reports
    Replies: 1
    Last Post: 01-25-2011, 04:12 PM
  5. Capture 2nd Value in an unbound Combo.
    By sesproul in forum Forms
    Replies: 5
    Last Post: 04-30-2010, 02:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums