Results 1 to 6 of 6
  1. #1
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159

    Change fields based on a combobox click

    Hi all,



    I have a form with two main fields.

    These fields are used to store dates for the purposes of identifying the time frame of all the records that are in a box.

    However, in a small few circumstances I need to be able to store PIN numbers to identify records that are in a box.

    So, basically I need a form that will only show two fields based on what is clicked in a combobox.

    In other words, instead of having four fields - 2 for date and two for numbers (both are mutually exclusive and aren't required on the form at the same time) or creating another form for the rare instances where I need to store numbers instead of dates - I would like the fields to change from date fields to number fields when a certain item in the combobox is clicked.

    So let's say I have dozens of categories like payroll, correspondence, claims, invoices, etc ----when I click invoices I want the default date fields to change to number fields instead.

    Is that clear as muddy water?

    Thanks in advance my mentors!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Can use VBA code to change the ControlSource property of the boxes when the form opens or use the Current event so that will change if navigating between records. And maybe the Change event of checkbox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    I must be learning because a couple of months ago I wouldn't have had the foggiest what you were talking about!

    Is it possible to do something similar for the label as well?

    Thanks.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Of course. You just have to change the label caption property.

  5. #5
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    I tried this but it didn't work. Need help before my eyes pop out of my head! ;-)

    Private Sub cboDesc_Change()

    If (cboDesc.Value = 5) Then

    [Forms]![frmFN_FilesBox]![frmFN_Box subform].Form.date_number.ControlSource = "fileStartNo"

    End If

    End Sub

    It keeps saying "the value you entered isn't valid for this field." Could it be related to changing the control source of a date field to a number field or am I just clutching at straws?

    Cheers Amigos!
    Last edited by Richie27; 05-31-2012 at 07:53 AM. Reason: left out .ControlSource

  6. #6
    Richie27 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Location
    Ireland
    Posts
    159
    S'okay. tis fixed. I just had to put in the .ControlSource bit above. Doh.

    It's always the little things.

    Three o'clock slump methinks!

    Thanks guys!

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

Similar Threads

  1. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  2. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  3. Replies: 6
    Last Post: 07-28-2011, 04:07 AM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 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