Opening Navigation form

MilaK

Registered User.
Local time
Today, 09:59
Joined
Feb 9, 2015
Messages
285
Hello,

I've created a Navigation Form with two tabs. It appears that Access renames all forms that are dropped in a tab as "NavigationSubform". I would like the Navigation Form to Open on a tab where "frmVariants" was dropped, when a textbox located on frmRuns is clicked. frmRuns is not a subform of a Navigation Form. Also, I would like to filter frmVariants based on a selected record from frmRuns.

Here is what I've tried:

Code:
DoCmd.BrowseTo acBrowseToForm, "frmVariants", "Navigation Form.NavigationSubform", , , acFormEdit
Forms!frmVariants!txtCurrentRun = Forms!frmRuns!Run_Name

I get an error message: invalid path that requires MainForm.subform>Form1.subform1 and I’m not sure what this means since I only have one level of subforms. Thanks
 
The error message is really a red herring sometimes. I've found that you get it when the form with the DoCmd.BrowseTo is still open sometimes. I suggest just for a test try.
Code:
DoCmd.Close
DoCmd.BrowseTo acBrowseToForm, "frmVariants", "Navigation Form.NavigationSubform", , , acFormEdit

If that gets you to the frmVariants ok then you just need to figure out how to pass the RunName. Probably the easiest way is just use TempVars.

Something like:

Code:
Dim RunName As TempVar
TempVars!RunName =  Forms!frmRuns!Run_Name
DoCmd.Close
DoCmd.BrowseTo acBrowseToForm, "frmVariants", "Navigation Form.NavigationSubform", , , acFormEdit

Then in the form open of frmVariants
Code:
Me.txtCurrentRun = TempVars!RunName
 
I get an error "tempvar can only store data, it can't strore objects" at line
TempVars!RunName = Forms!frmRuns!Run_Name
 
I thought Forms!frmRuns!Run_Name was a textbox or combo box. If it is please try

TempVars!RunName = Forms!frmRuns!Run_Name.Value

or

TempVars!RunName = Me.Run_Name.Value
 
yes,it is a name of a text box, however, temvar doesn't work for some reason.
I've tried to declare a global variable in main module and use it to pass the value to the control.

Global pass_run_name As String
pass_run_name = Forms!tblRuns!Run_Name
Debug.Print pass_run_name 'prints out the correct name

However, I can't figure out how to pass this value to a textbox on frmVariants that is attached to a Navigation Form.

Code:
[Forms]![frmVariants]![NavigationSubform].[Form].Controls("txtCurrentRun").Value = pass_run_name
doesn't work.

Please help:banghead:
 
That reference doesn't look right. I suggest trying

Code:
[Forms]![Navigation Form]![NavigationSubform].[Form].Controls("txtCurrentRun").Value = pass_run_name

or

Code:
[Forms]![Navigation Form]![NavigationSubform].[Form]!txtCurrentRun.Value = pass_run_name

Have you tried assigning it in the form open of the frmVariants form or isn't that firing on a BrowseTo?
 
Sorry one more quick question if you don't mind...

If I wanted to pass the same value to another subform of the "Navigation Form" frmCNV. It also has a textbox named txtCurrentRun and I would like to pass that value to that form also. How do I refence it correctly? Do I have to browse to it or can I just pass the value somehow?

Thank you very much.
 
This may sound weird but in a Navigation form only one form is open in the NavigationSubform at a time. Therefore the reference for the txtCurrentRun in the frmCNV form is the same as it is for the frmRuns form. If you put a button on the Navigation Form with the code
Code:
MsgBox [Forms]![Navigation Form]![NavigationSubform].[Form]!txtCurrentRun.Value

you can demonstrate to yourself that this is true.
 
Is it easier to pass "txtCurrentRun" value from frmVariants to frm_CNVs, since they are attached to the same navigation form, or not?

Also, I was trying to pass "pass_current_run" value to a query that reference txtCurrentRun on frmVariants and this statement failed. This query is attached to a listbox on a "Search" pop up form.

Code:
SELECT DISTINCT tblVariants.Sample_Type
FROM tblVariants
WHERE (((tblVariants.Run_Name)=[pass_run_name]));
Sorry, I'm asking so many questions, but this is very confusing. Perhaps, I should not use Navigation form ans stick to unattached forms. What do you suggest? Thanks
 
Is it easier to pass "txtCurrentRun" value from frmVariants to frm_CNVs, since they are attached to the same navigation form, or not?

Easier than what?. Typically a hidden textbox is place on the Navigation Form and that is used to pass information between the forms in the tabs. So let's say you call that hidden textbox txtHiddenBox you could populate it when one form closes in the close event with

Me.Parent.txtHiddenBox = Me.Whatever

Then in the form open of the other form just

Me.Whatever = Me.Parent.txtHiddenBox

Also, I was trying to pass "pass_current_run" value to a query that reference txtCurrentRun on frmVariants and this statement failed. This query is attached to a listbox on a "Search" pop up form.

Code:
SELECT DISTINCT tblVariants.Sample_Type
FROM tblVariants
WHERE (((tblVariants.Run_Name)=[pass_run_name]));

To use a global in a query you need a function to retrieve it. This Web page explain this. Can't you reference the value directly in this case instead of using the global?

Sorry, I'm asking so many questions, but this is very confusing. Perhaps, I should not use Navigation form ans stick to unattached forms. What do you suggest? Thanks

Don't worry about asking questions. That's what this forum is for. I think the Navigation Form presents a nice user interface. The alternative is typically a switchboard and the user has to click twice to get form one form to another. But working with the Navigation Form presents some challenges so it's really a matter of your time versus product presentation. How are you getting paid? It this a fixed price contract or time and materials? :D
 
I'm not a contractor but really pressed for time. I'm going to create a fake navigation form with buttons that look like tabs and chage color conditionally. I will probably remake all the forms later. Thanks so much for your help.
 

Users who are viewing this thread

Back
Top Bottom