Results 1 to 7 of 7
  1. #1
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35

    Performing an action after selecting a value from a combo box

    Hello all,



    I have a combox which selects 3 values i.e. 1 for patient is alive, 0 for patient is dead and 9 for unknown.

    I have some sub fields (made of textboxes or comboboxes)
    which should only appear if vital status= 0 is selected.

    for instance the deceased date, cause of death and so on should appear.

    I used a code like

    Private Sub cboVStatus_DropButtonClick()
    If Me.cboVStatus.Value = 0 Then
    Me.cboCauseTumor.Visible = False
    Me.txtDthdat.Visible = False
    Me.txtTumTyp.Visible = False

    Else If

    If Me.cboVStatus.Value = 1 Then
    Me.cboCauseTumor.Visible = True
    Me.txtDthdat.Visible.Visible = True
    Me.txtTumTyp.Visible = True

    Else If

    If Me.cboVStatus.Value = 9 Then
    Me.cboCauseTumor.Visible = False
    Me.txtDthdat.Visible.Visible = False
    Me.txtTumTyp.Visible = False

    End If

    End Sub

    any help?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    Code:
    Select Case Me.cboVStatus.Value
        Case 0
            Me.cboCauseTumor.Visible = True
            Me.txtDthdat.Visible.Visible = True
            Me.txtTumTyp.Visible = True
        Case Else
            Me.cboCauseTumor.Visible = False
            Me.txtDthdat.Visible.Visible = False
            Me.txtTumTyp.Visible = False
    End Select

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Try the following code in the After Update event of the combo:

    Code:
    Select Case Me.cboVStatus
       Case 0 
         Me.cboCauseTumor.Visible = False
         Me.txtDthdat.Visible = False
         Me.txtTumTyp.Visible = False
    
    
       Case 1 
         Me.cboCauseTumor.Visible = True
         Me.txtDthdat.Visible.Visible = True
         Me.txtTumTyp.Visible = True
    
    
       Case 9 
         Me.cboCauseTumor.Visible = False
         Me.txtDthdat.Visible.Visible = False
         Me.txtTumTyp.Visible = False
    
    
    End Select
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    angybab is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Oct 2020
    Posts
    35
    Thanks, it worked

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Thanks, it worked
    Glad you've fixed it but which one worked?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    I have never seen Me.whatever.Visible.Visible = whatever?

  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
    I have never seen Me.whatever.Visible.Visible = whatever?
    Ha! Ha! No neither had I till you pointed it out. I just copy/pasted and edited OP's code. I'm sure the second .Visible will need to be removed for it to work.

    I really shouldn't drink that red wine stuff so early in the day
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Selecting Value in Combo Box Automatically
    By Kevin Broecker in forum Forms
    Replies: 4
    Last Post: 06-08-2016, 02:22 PM
  2. Replies: 3
    Last Post: 12-15-2015, 12:36 PM
  3. Combo Box Not selecting value
    By data808 in forum Forms
    Replies: 3
    Last Post: 02-06-2014, 03:06 AM
  4. Replies: 1
    Last Post: 07-12-2012, 08:39 AM
  5. force action at combo box
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 03-01-2012, 11:21 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