?
Solved

Access - Tabbed form - Make form Hidden....

Posted on 2012-09-13
7
Medium Priority
?
597 Views
Last Modified: 2012-09-13
Good evening.

Have a tabbed form that when it opens all the tabs EXCEPT Page1 is hidden.  I want the tabs hidden until the user selects from a series of Command Buttons.  The selection will make Visible the appropriate tabs for the selected Command Button.

After it makes visible the correct tabs then I want it to hide that Page1.

However, I'm getting an error,
Run-Time error 2165
You can't hide a control that has the focus.

The problem I believe is when it gets to the bottom of the code, the last 4 lines after the Application.Echo True (Lines 44 to 48)

Though it is in fact making Page2 visible it isn't Setting the focus to the [txtCtlAmtIn] field

Thus when it hits Parent.Page1.Visible = False it is giving me that error.......

Private Sub cmdShiftEnd_Click()
    Dim cResponse As Integer, LResponse As Integer, lngMyRptgSeqID As Integer, lngMyShiftRptgLVLCtlID As Integer, strCriteria As String, strCriteria2 As String
    
    cResponse = MsgBox("You selected END OF SHIFT reporting.  Are you reporting Your End of Shift Information?", vbYesNo, "IS THIS YOUR END OF SHIFT REPORTING?")
        If cResponse = vbNo Then
            Exit Sub
        End If
    
    LResponse = MsgBox("Is this LVL Reporting for END OF DAY?", vbYesNo, "REPORTING END OF DAY?")
        
        Me.cboSelectedLVLRptgType.RowSource = "SELECT LVLRptgTypeID, LVLRptgType FROM LVLReportingType WHERE (((LVLRptgType)=" & "'Shift End'" & "))" & ";"
        Me.cboSelectedLVLRptgType = Me.cboSelectedLVLRptgType.ItemData(0)

 Application.Echo False
    
    Call NewLVLControl
    
    lngMyRptgSeqID = GetMyShiftSeqID()
    lngMyShiftRptgLVLCtlID = GetMyShiftRptgLVLCtlID()
    
    CurrentDb.Execute "INSERT INTO ShiftReportingEndCountCtl (ShiftRptgLVLCtlID, CountType) VALUES (" & lngMyShiftRptgLVLCtlID & "," & 1 & ")", dbFailOnError
    
    Call GenerateLVLMachineLines1(LResponse = vbYes)
    
    Parent.Page4.SetFocus
    Parent.Page4.Visible = True
    Forms![frm_DataReporting]![ShiftReportingLVL].Form![AmtOut].SetFocus
    Forms![frm_DataReporting]![ShiftReportingLVL].Controls("lblMachinePulled").Visible = False
    Forms![frm_DataReporting]![ShiftReportingLVL].Controls("MachinePulled").Visible = False
    Forms![frm_DataReporting]![ShiftReportingLVL].Form.Requery
    strCriteria = "[ShiftRptgLVLCtlID] = " & lngMyShiftRptgLVLCtlID
    Forms![frm_DataReporting]![ShiftReportingLVL].Form.Filter = strCriteria
    Forms![frm_DataReporting]![ShiftReportingLVL].Form.FilterOn = True
        
    Parent.Page6.SetFocus
    Parent.Page6.Visible = True
    strCriteria2 = "[ShiftRptgLVLCtlID] = " & lngMyShiftRptgLVLCtlID
    Forms![frm_DataReporting]![ShiftEndCashCount].Form.Filter = strCriteria2
    Forms![frm_DataReporting]![ShiftEndCashCount].Form.FilterOn = True
    Forms![frm_DataReporting]![ShiftEndCashCount]![ShiftRprgEndCountDetails_Coins].Form![Amount].SetFocus
    
Application.Echo True
    
    Parent.Page2.SetFocus
    Parent.Page2.Visible = True
    Forms![frm_DataReporting]![WVLVLControlTotals].Form![txtCtlAmtIn].SetFocus

    Parent.Page1.Visible = False
    
End Sub

Open in new window

0
Comment
Question by:wlwebb
  • 3
  • 2
  • 2
7 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 1000 total points
ID: 38397164
<<
  Parent.Page2.SetFocus
    Parent.Page2.Visible = True
>>

Try switching those two lines around.

Set focus *after* making it visible.
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 1000 total points
ID: 38397166
Are you just trying to hide the tabs?  Rather than go to all the trouble of setting pages to invisbile, you should just set the Style property of your tab control to None.  Personally, I like to do this by code, that way when I go in to design mode I can still quickly switch to the different pages.  In your Form's OnLoad event, just add Me.NameOfTabControl.Style = 2

Another thing I do with tabs is set the BackStyle property to transparent.  Try these out and see if it works for you.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38397178
Good stuff, Ron - I've never tried that.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:wlwebb
ID: 38397181
Mbiz...
That did it!!! Thanks.......  I'm not closing this yet to think about and try Irog's comment......
0
 

Author Comment

by:wlwebb
ID: 38397199
Irog...
I'm trying to prevent the user from being able to select the tab until they've completed the form preceeding/controlling form .....

If you think to the last couple days, this is the project where they are selecting control buttons for EndofShift or MachinePull or ClearChip.

Based upon which one they select it opens different tabs.

Thus In my example code above I would guess it would go
From this:
   Parent.Page2.Visible = True
    Parent.Page2.SetFocus
    Forms![frm_DataReporting]![WVLVLControlTotals].Form![txtCtlAmtIn].SetFocus

To this:
    Parent.Page2.SetFocus
    Forms![frm_DataReporting]![WVLVLControlTotals].Form![txtCtlAmtIn].SetFocus

Is that correct..... Other than the code in the onload event of the particular form...
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38397203
That is correct.  Just be sure to remove all your code to make pages visible or invisible.
0
 

Author Closing Comment

by:wlwebb
ID: 38397375
Thanks!  Like the alternative too
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

864 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