Results 1 to 14 of 14
  1. #1
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272

    Combo list selection to activate another field

    I have this access database form.
    I have a combo call “Comblist” which contains “Income” and “Expenditure” appearing in that drop down.




    And I have 2 other fields called “narration1” and “narration2”

    When I select “Income” from the combo list, I will like it to activate the field “narration1”

    When I select “Expenditure” from the combo list, I want it to activate “narration2”.

    I will also need the form to load with both “narration1” and “narration2” hidden unless the combo list criteria is met.

    Any help with this will be greatly appreciated.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Set the visible property of the narration textboxes in the after update event of the combo using select case or If/Then.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Bob Fitz View Post
    Set the visible property of the narration textboxes in the after update event of the combo using select case or If/Then.
    How do I go about it? We be glad if you could demonstrate it here for me
    So I can modify the code the suite my needs

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Form_Current()
    Call ComboListUpdate
    End Sub
    
    
    Private Sub Comblist_AfterUpdate()
    Call ComboListUpdate
    End Sub
    
    
    Public Sub ComboListUpdate()
    'made it publis so you can call it from other modules as needed
    Me.Naration1.Visible = Nz(Me.Comblist) = "Income"
    Me.Naration2.Visible = Nz(Me.Comblist) = "Expenditure"
    End Sub
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Gicu View Post
    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Form_Current()
    Call ComboListUpdate
    End Sub
    
    
    Private Sub Comblist_AfterUpdate()
    Call ComboListUpdate
    End Sub
    
    
    Public Sub ComboListUpdate()
    'made it publis so you can call it from other modules as needed
    Me.Naration1.Visible = Nz(Me.Comblist) = "Income"
    Me.Naration2.Visible = Nz(Me.Comblist) = "Expenditure"
    End Sub
    Cheers,
    Thanks
    Let me try it out and get back to you

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Or instead of setting visibility, could use Conditional Formatting to enable/disable - no VBA needed.
    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.

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Emmanuel View Post
    How do I go about it? We be glad if you could demonstrate it here for me
    So I can modify the code the suite my needs
    Take a look at the attached db
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Gicu View Post
    Code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Form_Current()
    Call ComboListUpdate
    End Sub
    
    
    Private Sub Comblist_AfterUpdate()
    Call ComboListUpdate
    End Sub
    
    
    Public Sub ComboListUpdate()
    'made it publis so you can call it from other modules as needed
    Me.Naration1.Visible = Nz(Me.Comblist) = "Income"
    Me.Naration2.Visible = Nz(Me.Comblist) = "Expenditure"
    End Sub
    Cheers,
    Where I put this code


    Public Sub ComboListUpdate()
    'made it publis so you can call it from other modules as needed
    Me.Naration1.Visible = Nz(Me.Comblist) = "Income"
    Me.Naration2.Visible = Nz(Me.Comblist) = "Expenditure"
    End Sub“

    Should I create a module for with that?

  9. #9
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    No, it goes in the form's module just like the other two subs .
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #10
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Bob Fitz View Post
    Take a look at the attached db
    Alright. Will check it out and see what I can make out of it.

    Will let you know of what comes out of it

  11. #11
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Quote Originally Posted by Bob Fitz View Post
    Take a look at the attached db
    Your dB helped a lot and I achieved the desired results.

    I noticed that after hiding some fields, I had

    “ DoCmd.GoToRecord , , acNewRec” not working after I save the record.

    Any suggestions please?

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    I will also need the form to load with both “narration1” and “narration2” hidden unless the combo list criteria is met.
    I thought this was also a requirement therefore having code only in the AfterUpdate event of the combo will not be enough...You should show us all the code not just one line. What does "not working" mean? Error, nothing happens, unexpected results?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  13. #13
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    I agree with Vlad. We need to see all your code. One line tells us nothing.

  14. #14
    Emmanuel is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2020
    Posts
    272
    Have been able to find a fix. Thanks to you all for your support

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

Similar Threads

  1. Combo list selection to activate a field
    By Emmanuel in forum Forms
    Replies: 7
    Last Post: 05-18-2021, 04:06 PM
  2. Replies: 2
    Last Post: 10-29-2019, 02:24 PM
  3. Replies: 10
    Last Post: 08-19-2018, 01:22 PM
  4. Replies: 3
    Last Post: 06-16-2018, 11:12 PM
  5. Replies: 1
    Last Post: 03-27-2012, 07:10 AM

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
  •  
Other Forums: Microsoft Office Forums