Solved

Hiding a control (but not really)

Posted on 2006-06-16
11
294 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:ExpExchHelp
  • 6
  • 4
11 Comments
 
LVL 10

Expert Comment

by:LenaWood
ID: 16922744
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
 
LVL 28

Expert Comment

by:omgang
ID: 16922761
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
 

Author Comment

by:ExpExchHelp
ID: 16922791
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
 
LVL 10

Expert Comment

by:LenaWood
ID: 16922827
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
 
LVL 10

Expert Comment

by:LenaWood
ID: 16922853
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:ExpExchHelp
ID: 16922936
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
 
LVL 10

Expert Comment

by:LenaWood
ID: 16922946
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
 

Author Comment

by:ExpExchHelp
ID: 16923034
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
 
LVL 10

Accepted Solution

by:
LenaWood earned 125 total points
ID: 16923083
Try re-enabling your combobox.  Leave it locked and not a tab stop.
0
 

Author Comment

by:ExpExchHelp
ID: 16923110
Yep... that works great... thanks so much Lena.

EEH
0
 
LVL 10

Expert Comment

by:LenaWood
ID: 16923145
Anytime
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now