Hiding a control (but not really)

I have a control (combo box) that needs to be "hidden".   However, several functions SetFocus on the control (I also need it for calculating an IndexCount).  

When I actually changed "Visible" = No... the Access form caused several errors.  

I tried to just "lay" another control (e.g. box and unbound textbox) on top of the combo.   Then (for testing purposes) I changed box/textbox's background color to yellow.   Later on I would change it to the actual form background color (light gray)...

Unfortunately, that idea (to hide the combo behind a box) doesn't work... although I see the yellow box... the combo is still visible/active inside the yellow background shape.

I also set the combo's width to something like 0.001... now it appears like a "vertical" bar... but it's still obvious to see.

Any ideas how to make the combo "invisible" WITHOUT setting its Visible property to No?

Thanks,
Tom
ExpExchHelpAsked:
Who is Participating?
 
LenaWoodConnect With a Mentor Commented:
Try re-enabling your combobox.  Leave it locked and not a tab stop.
0
 
LenaWoodCommented:
Click on the yellow box and go to format and choose to bring to front.  Make sure your yellow box is a hair taller and wider than your combo box.  I am not sure why you are wanting it "hidden".  What if you set it to locked...so that the value couldn't be changed.
0
 
omgangIT ManagerCommented:
I think you're asking a bit too much.  How to make something invisible and still visible.  Do you not want it to function or do you not want to see it?  You can disable it by setting the Enabled property - it'll still be visible but users won't be able to select it.

OM Gang
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
ExpExchHelpAuthor Commented:
Thanks to both of you...

LenaWood:
I tried the "Move to Front" for the rectangle... the combo still "shines" through it.   I think you're onto something... what am I missing?

OMGang:
I want the combo to function (call it "running in the background").   I don't want users to "use it though".   Now, why do I show something that can't be changed... so, that's why I'm trying to make it insivible.   Setting it truly to invisible it's not going to work.

EEH
0
 
LenaWoodCommented:
EEH,

Lets try something

Remove the label associated with your combo box.

On your combo boxes preferences do this:

On the data tab set Enabled to False, Locked to True
on the "Other" tab, change Tab Stop to no
On the format tab set the height to 0, the width to 0, set the borderstyle and back style to transparent.

You shouldn't be able to see it

To select it to make changes to it if needed, you will have to find it using the drop down box that shows all your controls on your tool bar.

Lena
0
 
LenaWoodCommented:
Now your box should cover your combo box if it is in front...and your box doesn't have to be so big.

You really don't have to make your combo box so small if you do the rest of what I said to do...I usually make things pretty small that I am not really needing to show.  Easier to move them into a vacant space and not cover open space that I could put something else...just neater in design view.

Lena
0
 
ExpExchHelpAuthor Commented:
Lena,

I tried what you said... once I changed Enabled=False, Locked=True, the function "blow up" again.   I set the width and height to 0... now, it's only a very tiny shape (still visible yet).   The rectangle on top still doesn't hide it when the functions set focus on it.

While I'm still not there yet... it's already much better.  

EEH
0
 
LenaWoodCommented:
How did the function blow up?  What is your function doing?

I tried this on a database of mine and everything was hidden nicely.

Lena
0
 
ExpExchHelpAuthor Commented:
Here's the code... the combo that gives me the problems is "cboIndex".   I can easily hide the custom navigation buttons such as "cmdGotoFirst".

I don't want to change the code too much... but if you know of anything obvious, I'd appreciate the feedback.

EEH




Option Compare Database
Option Explicit

Private Sub Form_Load()
   
    'Retrieves the cached combo box value for cboParticipantID (basComboBoxValuePassing)
    Me.cboParticipantID = strCombo1
    Me.txtCredentialID = strCombo2
    Me.txtSurveySession = strCombo3
   
    Me.txtLoginConcatenate = " You are logged in as participant: " & strCombo1
   
    'Determines current DateTimeStamp (DTS) for beginning of survey
    Me.DTS_Start_Temp = Now()
   
End Sub

Private Sub Form_Open(Cancel As Integer)

    'Maximizes frmSurvey when opened
    DoCmd.Maximize

    'Add a temporary value to Participant.  This automatically creates a record and reference.
    Me.txtLoginConcatenate.SetFocus
    Me.ParticipantID.Value = "0000"
    Me.cboIndex.Value = Me.cboIndex.ItemData(0)
    Me.cboIndex.SetFocus    'Unhide if cboIndex properties is changed from Invisible to Visible

End Sub

Private Sub cmdGotoFirst_Click()

    'Navigate to the first index
    With Me.cboIndex
        .Value = .ItemData(0)
        .SetFocus
    End With

End Sub

Private Sub cmdGotoLast_Click()

    'Navigate to the last index
    With Me.cboIndex
        .Value = .ItemData(.ListCount - 1)
        .SetFocus
    End With
   
End Sub

Private Sub cmdGotoPrevious_Click()

    'Navigate to previous index
    With Me.cboIndex
        If .ListIndex Then .Value = .ItemData(.ListIndex - 1)
    End With
    Me.Recalc
   
End Sub

Private Sub cmdGotoPrevious_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

    'Set focus to previous index
    Me.cboIndex.SetFocus
   
End Sub

Private Sub cmdGotoNext_Click()

    'Navigate to next index
    With Me.cboIndex
        If .ListIndex < .ListCount - 1 Then .Value = .ItemData(.ListIndex + 1)
    End With
    Me.Recalc
   
End Sub

Private Sub cmdGotoNext_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

    'Set focus to next index
    Me.cboIndex.SetFocus

End Sub

Private Sub cboIndex_GotFocus()

    'Sets focus to "top question" of next selected index.  Without this function, the "glitch" occurs.
    'For instance, if two or more consecutive indices have at least six questions, the selection of the
    'next index sets focus on the 6th question.  Hence, it's easy to skip some questions.
    On Error Resume Next
    Me.subAnswers.Form.Recordset.MoveFirst

End Sub

Private Sub cmdGeneralQuestion_Click()

    'Open pop-up form
    DoCmd.OpenForm "01_fsubPopUpSurveyInfo"
   
End Sub

Public Function Progress(plngPos, plngCount As Long) As Double
     
     'Show graphic progress (completion) bar
     Progress = plngPos / plngCount
     recProgressBar.Width = Progress * recProgressContainer.Width
     If plngPos + 1 < plngCount Then
         cmdContinue.Caption = "&Continue survey..."
     Else
         cmdContinue.Caption = "Submit survey!"
     End If
     
End Function

Function IndexDone(pfShowMsg As Boolean) As Boolean

     DoEvents
     subAnswers.SetFocus
     With subAnswers.Form
         .Recordset.MoveFirst
         Do Until .Recordset.EOF
             If IsNull(!Answer) Then
                 If pfShowMsg Then _
                     MsgBox "Please answer this question!", vbInformation, "Missing Data"
                 !cboAnswer.SetFocus
                 !cboAnswer.Dropdown
                 Exit Function
             End If
             .Recordset.MoveNext
         Loop
     End With
     IndexDone = True

End Function

Private Sub cmdContinue_Click()

     'Check current index and move to next
     If IndexDone(False) Then
         If cboIndex.ListIndex + 1 < cboIndex.ListCount Then
             cmdGotoNext_Click
             Me.subAnswers.Form.Recordset.MoveFirst
             Me.subAnswers.SetFocus
         ElseIf MsgBox("Submit Rock Drill survey now?" & vbCrLf _
                     & "Survey validation will take a moment." & vbCrLf _
                     & "Do not close Rock Drill survey application until prompted!", vbInformation + vbOKCancel, "Survey Status") = vbOK Then
             cmdSubmit_Click
         End If
     End If

End Sub

Private Sub cmdSubmit_Click()

    'Check survey answers for completion
    cmdGotoFirst_Click
    Do Until cboIndex.ListIndex + 1 = cboIndex.ListCount
        If Not IndexDone(True) Then Exit Sub
        cmdGotoNext_Click
    Loop
    If Not IndexDone(True) Then Exit Sub

    'Determines current DateTimeStamp (DTS) for ending of survey
    Me.DTS_End_Temp = Now()

    'Updates the temporary values and overwrites them with permanent survey data
    Me.ParticipantID = Me.cboParticipantID
    Me.SurveySession = Me.txtSurveySession
    Me.DTSSurveyStart = Me.DTS_Start_Temp
    Me.DTSSurveyEnd = Me.DTS_End_Temp

    MsgBox "Thank you for completing the Rock Drill survey!", vbInformation, "Survey Status"

    'Quit the Rock Drill application
    DoCmd.Quit

End Sub

0
 
ExpExchHelpAuthor Commented:
Yep... that works great... thanks so much Lena.

EEH
0
 
LenaWoodCommented:
Anytime
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.