Please help,
I have a navigation form with 2 top tab's. The left tab (Log In) is visible and has the focus on if the database opens. The tab contains only 2 text boxes for the username and password and has no left side tabs. The other top tab (Job Bag) has 5 left side tabs and is invisible. The user logs in and the right side tab on the top becomes visible. I search for more than a week and cant get it done that I can set the focus on one of the left side tabs on the right top tab. I get the focus changed to the right side tab, but I don't get the focus on one of the left side tabs.
The line below sets the focus on the right tab (Job Bag), but I cant finish the next level to get the focus and view on one of the left side tabs. - Forms!NavigationForm!tabJobEntry.SetFocus
I know this subject is discussed in many places and I tried by myself, but I can't get it done and any help would be really appreciated. 14 3942 zmbd 5,501
Expert Mod 4TB
ACC2010 and newer navigation controls (navctrl) are a love hate tool.
I love the ease, I like the fact that the forms late load, and that they load fresh each time, I hate the reference methods.
You must keep in mind, these are NOT tab control forms.
Very little of what you have learned about tab control forms is applicable to the navcltrl.
I have a similar two-tiered navctrl.button grouping and I often need to move between the second tier or from the tier1 group1 to the tier group2 buttons.
This is most likely the best route for what you want. - DoCmd.BrowseTo _
-
objecttype:=acBrowseToForm, _
-
objectname:="Name_of_Form_Bound_to_NavCtrlButton", _
-
PathtoSubformControl:="frm_navigation.navigationsubform"
-
', WhereCondition:="RecordsetField = " & [inthiscasenumeric]
-
Change Line 3 to the name of the form that your navctrl.button("Job Overview") loads
Line 4, you will have to change the names to the parent and child names. I used the default navctrl.subformctrl name of "navigationsubform" this is the container that the navctrl loads your actual subform in.
I commented out the wherecondtion; however, that works just like any of the form filters and is a handy way to pass information between the currently loaded form and the one to load... keep in mind, this sets the filter on the form to be loaded!
Let’s say I’ve just loaded the form so I'm in [Tier1(button1):Tier2(button1)] and I need to go to the [Tier1(button3):Tier2(button4)], if the form named “sfm_T1B3T2B4” is associated with this navctrl.button, then this is how the above would work - DoCmd.BrowseTo _
-
objecttype:=acBrowseToForm, _
-
objectname:=" sfm_T1B3T2B4", _
-
PathtoSubformControl:="frm_navigation.navigationsubform"
-
And the [tier1 button 3, tier 2 button4] would be selected.
Hi zmbd,
I took the code you suggested and changed to: - DoCmd.BrowseTo _
-
objecttype:=acBrowseToForm, _
-
objectname:="frmJobOverview", _
-
PathtoSubformControl:="NavigationForm.NavigationSubform"
It does not go thru. The right top tab is selected, but the desired left side tab is not and the form wont open. It is almost the same as I got with the line from my first post.
Do I need a indication for the top tab and the left tab?
Z,
ACC2010 and newer navigation controls (navctrl) are a love hate tool
Do you have any history or intuition on why MS would give us such a lovely tool that is so difficult to use? It's like installing new anti-lock brakes on a car, but they only work when your left turn signal is on and your radio is tuned to 87.5. Yeah, they'll work but it takes some practice.
I hesitate to incorporate the Nav Controls because of hte non-stop problems I see people having with them. I'd just like to know if you've heard anything about "why"?
zmbd 5,501
Expert Mod 4TB
Tier one will mean the top, main group of navctrl.buttons
Tier two will mean any buttons that are linked to the top row of navctrl.buttons
Open the form containing the navigation control in design mode.
Select the first tier button that contains your second tier button group
Right click on the second tier button that you want to have selected and show properties.
All tab
Forth property, [Navigation Target Name]
This is the name that you need to place in line 3.
Hi zmbd,
this is exactly what I did. See the attachment. It still just selects the right tab and is not displaying all left tabs. It looks like kind of corrupted, only the top first button appears, all others are missing and the form is not displayed, it stays on the log in form from the left top tab.
Isn't there a way to go with .setfocus as I tried in the first post? Is the DoCmd the only way? zmbd 5,501
Expert Mod 4TB
The docmd.browse is the only method to trip the navctrl.control actions.
You must have ALL of the subforms saved and CLOSED before opening the form with the navctrl
Please post your revised vba code behind the call...
actually lets see the entire code block around the docmd.
You should do a compile and fix any errors as described before you post the code following the recomendations here:[*] > Before Posting (VBA or SQL) Code.
Also, from your picture I cannot tell what the name of the navigation target is, please post that information as well.
Hi zmbd,
can you give me a mail address that I could send you the entire database? Sascha
zmbd 5,501
Expert Mod 4TB
No need to send the database yet, besides I would not be able to open the database at work as we have a secured IT environment (makes visiting image and file dump sites (that's right, no google drive for me!) impossible etc...). (-_-)
Please provide the information I have requested.
The code block
and the value from the [navigation target] property of the navctrl.button you wish to navigate to.
Hi zmbd,
the code is on the Log In form of my database and suppose to switch to the desire form after log in. See below code and the navigation target of the form I like to open.
Navigation Target: frmJobOverview - Option Compare Database
-
Option Explicit
-
-
Private Sub Form_Open(Cancel As Integer)
-
txtPassword.SetFocus
-
End Sub
-
-
Private Sub txtPassword_AfterUpdate() ' Username and password verification
-
-
' Use DAO database to look up user and verify password
-
' to allow tabs and menues as per setting in tbl Users
-
-
On Error GoTo errorHandler
-
-
Dim dbs As DAO.Database
-
Dim rstUser As DAO.Recordset
-
Dim strPassword As String
-
Dim strUserName As String
-
Dim strEntPass As String
-
-
strUserName = IIf(IsNull(Me.txtUserName), "", Me.txtUserName)
-
strEntPass = IIf(IsNull(Me.txtPassword), "", Me.txtPassword)
-
-
If strUserName = "" Then ' In case of empty username
-
Me.txtUserName.SetFocus
-
Me.txtPassword.Value = ""
-
Exit Sub
-
End If
-
-
Set dbs = CurrentDb
-
Set rstUser = dbs.OpenRecordset("tblEmployee", dbOpenDynaset)
-
-
rstUser.FindFirst "[EmployeeLogIn] = '" & strUserName & "'"
-
-
If rstUser.NoMatch Then ' In case user is not set up
-
MsgBox "User is not available...please log on with other name!"
-
Me.txtUserName.Value = ""
-
Me.txtPassword.Value = ""
-
Me.txtPassword.SetFocus
-
Me.txtUserName.SetFocus
-
Else
-
strPassword = rstUser!EmployeePassword ' If available, get password and user level
-
gBytUserLevel = rstUser!EmployeeUserLevel
-
gBytDepartment = rstUser!DepartmentID
-
End If
-
-
If strEntPass = strPassword And gBytUserLevel = 1 Then ' User level 1, all tabs visible
-
-
gStrUserName = strUserName
-
-
Forms!NavigationForm.tabLogIn.Caption = "Log Out"
-
Forms!NavigationForm.tabJobEntry.Enabled = True
-
Forms!NavigationForm.tabPlanning.Enabled = True
-
Forms!NavigationForm.tabScheduling.Enabled = True
-
Forms!NavigationForm.tabReporting.Enabled = True
-
Forms!NavigationForm.tabSetting.Enabled = True
-
Forms!NavigationForm.tabJobEntry.Visible = True
-
Forms!NavigationForm.tabPlanning.Visible = True
-
Forms!NavigationForm.tabScheduling.Visible = True
-
Forms!NavigationForm.tabReporting.Visible = True
-
Forms!NavigationForm.tabSetting.Visible = True
-
-
-
ElseIf strEntPass = strPassword And gBytUserLevel = 2 Then ' User level 2, settings off
-
-
gStrUserName = strUserName
-
-
Forms!NavigationForm.tabLogIn.Caption = "Log Out"
-
Forms!NavigationForm.tabJobEntry.Visible = True
-
Forms!NavigationForm.tabPlanning.Visible = False
-
Forms!NavigationForm.tabScheduling.Visible = False
-
Forms!NavigationForm.tabReporting.Visible = False
-
Forms!NavigationForm.tabJobEntry.Enabled = True
-
Forms!NavigationForm.tabPlanning.Enabled = False
-
Forms!NavigationForm.tabScheduling.Enabled = False
-
Forms!NavigationForm.tabReporting.Enabled = False
-
Forms!NavigationForm.tabSetting.Visible = False
-
-
DoCmd.BrowseTo _
-
objecttype:=acBrowseToForm, _
-
objectname:="frmJobOverview", _
-
PathtoSubformControl:="NavigationForm.NavigationSubform"
-
-
ElseIf strEntPass = strPassword And gBytUserLevel = 3 Then ' User level 3, settings, reporting, etc off
-
-
gStrUserName = strUserName
-
-
Forms!NavigationForm.tabLogIn.Caption = "Log Out"
-
Forms!NavigationForm.tabJobEntry.Visible = True
-
Forms!NavigationForm.tabPlanning.Visible = False
-
Forms!NavigationForm.tabScheduling.Visible = False
-
Forms!NavigationForm.tabReporting.Visible = False
-
Forms!NavigationForm.tabJobEntry.Enabled = True
-
Forms!NavigationForm.tabPlanning.Enabled = False
-
Forms!NavigationForm.tabScheduling.Enabled = False
-
Forms!NavigationForm.tabReporting.Enabled = False
-
Forms!NavigationForm.tabSetting.Visible = False
-
-
Else
-
-
Me.txtUserName.Value = ""
-
Me.txtPassword.Value = ""
-
-
End If
-
-
'Call currentUserName(strUserName) ' Store the log in name in function
-
-
rstUser.Close
-
dbs.Close
-
-
Set rstUser = Nothing
-
Set dbs = Nothing
-
-
Exit Sub
-
-
errorHandler:
-
-
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
-
-
End Sub
zmbd 5,501
Expert Mod 4TB
Just a quick view, the lab was filled with Gremlins... wish someone would quit pouring water on them, anyway, I've the kids to feed so a quick pop in and the youngest is helping me type so forgive the typos :P
I would think that Lines 79 thru 82 should go after the if..then..else-if structure... around line 105 (I prefer the select...case structure instead of the if/the/else-if stack, just me (^_^))
If the buttons are not enabled at the time of call for the browse to command, there can be some goofiness.
Place a STOP at line 40 and execute the form.
Once the code breaks to debug mode, [f8] to step thru the code and make sure that the entire code is executing as expected. If possible arrange things so that you can see both the form and the code at the same time. I have a dual monitor that makes this easy so that I can have the vbe open and the database gui open at the same time. Often, computers will come with a graphics card that most people use and then there's a legacy VGA port ... two tuners... two monitors and WinXP and newer can take advantage of both ports. I highly advise it if you have a spare monitor and the real-estate.
STEP THIS SLOWLY... if we're looking at a timing issue, which can happen when the code runs at full speed, the human touch may slow things down enough that the flags get set and updated before the command to browse to the form is called. Been many a time for me that the code works as expected in [F8] but not at full tilt - solution is simple, loop until flag state shows correctly (and I usually place a trouble counter too to prevent infinite loops).
> " frmJobOverview " > Just double checking, this is the copy and paste directly from the control property window... or did you type it into the post. Please be patient with me asking this question, it's vital to the overall solution.
Sorry for the late reply, but we had holidays here in Saudi Arabia and I did not touch my computer for a couple days.
I did as you suggested and put it in select case form. I added a function to pause the code with 3 or 5 seconds before the docmd part. It is ending up exactly the same as before. I wend thru each line in debug mode and could not see any flaw. See the attached pic, this is how the desired form opens. Only 2 items are visible on the left side and one of them looks even kind of corrupted or defective and the top one is still from the previous form "Log In". If I hover over the other tabs, they become visible. Maybe this description is helpful for you...I copied and pasted the navigation target and check already multiple times for correctness. zmbd 5,501
Expert Mod 4TB
That's OK, I understand, Our Holidays/Holy Days are important to recharge the mind, the body, the sprit and our relationship with God. (^_^) At times it would be nice if the US would allow such days in each faith to be observed as days away from work. However, with the number of different faiths we have it would make running a business very difficult.
Anyway I digress:
Lets add one more line of code,
Right before the DoCmd.BrowseTo
insert Forms!NavigationForm.Repaint
This should update your form's GUI.
Otherwise, Please post your newest code and I'll run it thru my test data base later this afternoon. I have a meeting this morning that will eat-up a lot of my day... nice break from the routine; however, it puts me behind for the day.
I tried with the repaint and it ends up exactly as without. Here is the current code also. I get the feeling that the database might be corrupted or defective somehow. - Private Sub txtPassword_AfterUpdate() ' Username and password verification
-
-
' Use DAO database to look up user and verify password
-
' to allow tabs and menues as per setting in tbl Users
-
-
On Error GoTo errorHandler
-
-
Dim dbs As DAO.Database
-
Dim rstUser As DAO.Recordset
-
Dim strPassword As String
-
Dim strUserName As String
-
Dim strEntPass As String
-
-
strUserName = IIf(IsNull(Me.txtUserName), "", Me.txtUserName)
-
strEntPass = IIf(IsNull(Me.txtPassword), "", Me.txtPassword)
-
-
If strUserName = "" Then ' In case of empty username
-
Me.txtUserName.SetFocus
-
Me.txtPassword.Value = ""
-
Exit Sub
-
End If
-
-
Set dbs = CurrentDb
-
Set rstUser = dbs.OpenRecordset("tblEmployee", dbOpenDynaset)
-
-
rstUser.FindFirst "[EmployeeLogIn] = '" & strUserName & "'"
-
-
If rstUser.NoMatch Then ' In case user is not set up
-
MsgBox "User is not available...please log on with other name!"
-
Me.txtUserName.Value = ""
-
Me.txtPassword.Value = ""
-
Me.txtPassword.SetFocus
-
Me.txtUserName.SetFocus
-
Else
-
strPassword = rstUser!EmployeePassword ' If available, get password and user level
-
gBytDepartment = rstUser!DepartmentID
-
gBytUserLevel = rstUser!EmployeeUserLevel
-
End If
-
-
Select Case gBytUserLevel
-
-
Case 1 And strEntPass = strPassword ' User level 1, all tabs visible
-
-
gStrUserName = strUserName
-
-
Forms!NavigationForm.tabLogIn.Caption = "Log Out"
-
Forms!NavigationForm.tabJobEntry.Enabled = True
-
Forms!NavigationForm.tabPlanning.Enabled = True
-
Forms!NavigationForm.tabScheduling.Enabled = True
-
Forms!NavigationForm.tabReporting.Enabled = True
-
Forms!NavigationForm.tabSetting.Enabled = True
-
Forms!NavigationForm.tabJobEntry.Visible = True
-
Forms!NavigationForm.tabPlanning.Visible = True
-
Forms!NavigationForm.tabScheduling.Visible = True
-
Forms!NavigationForm.tabReporting.Visible = True
-
Forms!NavigationForm.tabSetting.Visible = True
-
-
-
Case 2 And strEntPass = strPassword ' User level 2, settings off
-
-
gStrUserName = strUserName
-
-
Forms!NavigationForm.tabLogIn.Caption = "Log Out"
-
Forms!NavigationForm.tabJobEntry.Visible = True
-
Forms!NavigationForm.tabPlanning.Visible = False
-
Forms!NavigationForm.tabScheduling.Visible = False
-
Forms!NavigationForm.tabReporting.Visible = False
-
Forms!NavigationForm.tabJobEntry.Enabled = True
-
Forms!NavigationForm.tabPlanning.Enabled = False
-
Forms!NavigationForm.tabScheduling.Enabled = False
-
Forms!NavigationForm.tabReporting.Enabled = False
-
Forms!NavigationForm.tabSetting.Visible = False
-
-
Case 3 And strEntPass = strPassword ' User level 3, settings, reporting, etc off
-
-
gStrUserName = strUserName
-
-
Forms!NavigationForm.tabLogIn.Caption = "Log Out"
-
Forms!NavigationForm.tabJobEntry.Visible = True
-
Forms!NavigationForm.tabPlanning.Visible = False
-
Forms!NavigationForm.tabScheduling.Visible = False
-
Forms!NavigationForm.tabReporting.Visible = False
-
Forms!NavigationForm.tabJobEntry.Enabled = True
-
Forms!NavigationForm.tabPlanning.Enabled = False
-
Forms!NavigationForm.tabScheduling.Enabled = False
-
Forms!NavigationForm.tabReporting.Enabled = False
-
Forms!NavigationForm.tabSetting.Visible = False
-
-
Case Else
-
-
Me.txtUserName.Value = ""
-
Me.txtPassword.Value = ""
-
-
End Select
-
-
Forms!NavigationForm.Repaint
-
-
DoCmd.BrowseTo _
-
objecttype:=acBrowseToForm, _
-
objectname:="frmJobOverview", _
-
PathtoSubformControl:="NavigationForm.NavigationSubform"
-
-
'Call currentUserName(strUserName) ' Store the log in name in function
-
-
rstUser.Close
-
dbs.Close
-
-
Set rstUser = Nothing
-
Set dbs = Nothing
-
-
Exit Sub
-
-
errorHandler:
-
-
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
-
-
End Sub
-
zmbd 5,501
Expert Mod 4TB
Sapo,
Not sure what is going on with your form.
I pulled your code into my generic test database and ran it thru... I even altered the target forms etc... always seemed to work as expected.
You may have something goofy with your form and recreating and pulling the form's objects back in will fix.
I've attached the test database... not 100% like yours, just the navigation form and some supporting forms and tables with generic stuff as this isn't supposed to be a working database (^_^)
-z
[edit] Take a look at your subform, frmJobOverview, if there is something wrong with this form (missing recordset, errors in bound controls, etc) it can cause issues with the loading into the navctrl.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Trev Hunter |
last post by:
Hi Folks,
Sorry if you have seen this post before - I've posted it before, but it
seems to have gotten lost in Outlook limbo - it's visible on the web
interface, but not in any news reader I've...
|
by: Jens Körte |
last post by:
Hi NG!
I encountered some strange behaviour when using focus()
I use a form with several input-fields. A user can enter stuff. After
entering I want to check the value, i.e. that a number is...
|
by: please-answer-here |
last post by:
What is wrong with this code?
when i place "return false" before the xfab assignment the form as intended
doesn't submit. But when placed as here or in the last if/else construct the
page gets...
|
by: Robert Oschler |
last post by:
I have a textarea element that I have created an onblur() handler for.
In the onblur() handler, I check to make sure that they have saved the
contents of the edit box, before leaving it.
If...
|
by: Neil Ginsberg |
last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a
form with a subform (in continuous form view). A combo box on the main form
has code in the AfterUpdate event which adds a...
|
by: jab3 |
last post by:
Hello. I"m new to this group, and to JavaScript in general, so please
forgive me if I breach local etiquette. I'm trying to implement some
client-side 'dynamic' validation on a form. I'm having...
|
by: Michel Posseth [MCP] |
last post by:
Hello we have encountered the following problems with the date time picker
control
A : datetime picker control gives focus to last entered field when moving
back and forward with focus how do...
|
by: jan.loucka |
last post by:
Hi,
I looked around for this specific problem but could not find any
answer - there's few things in VB but still nothing exactly like this
so I'd appreciate any help.
We're writing C# WinForm...
|
by: ramdil |
last post by:
Hi All
I have a form with section and multiple pages(tab sections) in the section.Now i have added a button in the form which when clicked will open a form.Now my problem is that when i click the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |