I have a form called frmAanlog with a NavigationControl on it. Using vba I would like to move to one of the forms that you normally reach by clicking on a NavigationButton in the Navigation Control. The form I would like to reach is called frmNavPlant.
I have tried variations of the following line, without success:
DoCmd.BrowseTo acBrowseToForm, "frmNavPlant", "frmAanlog.frmNavPlant"
Any suggestions here?
Preferably I would jump to a specific record-ID in frmNavPlant, but already happy with a working jump to the correct form, with the NavigationControl indicating the right page.
Must reference Navigation Form subform container control name, not form name, in Path argument. Access defaults to NavigationSubform when Navigation Form is created.
DoCmd.BrowseTo acBrowseToForm, "frmNavPlant", "frmAanlog.NavigationSubform"
Related
In my access project, I have Navigation form named DepartmentMgtWindow and one of its subform is named DepartmentPanel. In my DepartmentPanel I also have subform/subreport that target a form named PcnsList, where PcnsList is a continuous form. Consider the image below:
In my event (On Open) for DepartmentMgtWindow, I want to hide PcnsList hence the code:
Private Sub Form_Open(Cancel As Integer)
Form_PcnsList.Visible = False
End Sub
When I run the project, my access suddenly crashes and gets Microsoft Access has stopped working, and if I comment out the code inside the event it works fine.
I also put On Open event in my DepartmentPanel and I am getting the same result.
Any help/suggestions are highly appreciated.
Code fails because form PcnsList is not open as an independent object and therefore is not in active Forms collection.
Subform path referencing must be through container names, not form names.
Looks like PcnsList is on a form that is loaded as Navigation Target. Access assigns container that holds target forms a name of NavigationSubform by default. So if the embedded subform container control is named PcnsList and code is behind DepartmentMgtWindow form, try (yes, that is the word Form, do not replace with a form name):
Me.NavigationSubform.Form.PcnsList.Visible
I always give container control a name different from object it holds, like ctrPCN, then:
Me.NavigationSubform.Form.ctrPCN.Visible
For code behind DepartmentPanel: Me.ctrPCN.Visible = True
However, advise to set PcnsList subform container as not visible in its design and then code makes visible when needed. This would eliminate problem code from main form.
I've taken over a project, which contains some UltraWinGrid controls on some of the forms.
On one of the original forms which has been there since before I took on the project, there is a ContextMenuStrip, which has just one ContextMenuToolstripItem on it, captioned 'Default for Column'.
This ContextMenuStrip is hidden by default, however, when the user right-clicks on the UltraGrid, the ContextMenuStripItem is displayed on the grid (rather than at the top of them form where the ContextMenuStrip is).
I'm trying to replicate this behaviour in a new form that I've added myself, however, after adding the ContextMenuToolstripItem in, I cannot get it to display when right-clicking my grid.
I've put a breakpoint on every subroutine in the in the older forms class, and none of them are triggered when right-clicking it.
Additionally I have also searched the class for DefaultForColumnToolstripMenuItem, and the only place it appears is in the Click event of the ContextMenuToolStripItem itself.
So, how else is it possible to show it when right-clicking the grid? I've copy and pasted the ContextMenuStrip from the old form onto the new form and still nothing occurred.
I'm assuming it's in a property somewhere that I'm missing?
Check for a ContextMenuStrip property on the UltraWinGrid. You can set it in the designer and your context menu will appear on right click without having to deal with the MouseClick handler, checking the mousebutton used, etc.
I have created the following navigation structure in a Microsoft access 2010 database:
You can see that there are two tabs, and the data for the tabs is populated with information linked to the ClientID, which is stored in an un-editable textbox at the top of the form. When the Communications Forms tab is selected, a list of communications forms that have been completed for the specific ClientID is shown. And there is a button to create a new form. My question is how do I write the macro so that clicking on the Create New Form button will cause a blank new form to be loaded in the space that is currently occupied by the List of Forms?
Below is what I have so far. It sends the user to a new form instead of embedding the new form underneath the Communication Forms tab in the current form. How can I change the below so that the blank new form is loaded under the Communication Forms tab in the current form, so that all the navigation controls remain visible/usable?
EDIT:
To address HK1's assumptions below, I am adding the following description of the steps I took to create the form in the screenshot above:
1.) I created a blank form in design view.
2.) I added a listbox to list client fullname and id, and a textbox to filter the listbox.
3.) I added the clientid and fullname textboxes to the form, and set them to change based on
what the user selects from the listbox
4.) I dragged a navigation control onto the form next to the listbox
5.) I dragged a form called "ListOfForms" onto a new tab in the navigation control to create the tab
6.) I added the CreateNewForm command button to the ListOfForms form while embedded in the main form
Here is the result of HK1's suggested code:
While I appreciate it, it does not do what I need. You can see that it just adds an additional row to the list in ListOfForms. Instead, I need the code to place a blank MyForm in the place of MainForm where ListOfForms is currently located. Thus, under the CommunicationsForms tab, all the user would see would be a blank MyForm object, which is a different form than ListOfForms.
When I click on the place where ListOfForms is located in Layout View, I see that it is called NavigationSubForm in the Property Sheet. Thus, NavigationSubForm would swap in MyForm in place of ListOfForms when the user clicks on the Create New Form command button. But if the user clicks on CommunicationForms tab again, ListOfForms would again be placed in NavigationSubForm.
I tried the following:
Private Sub cmdCreateNewForm_Click()
Forms!MainForm!NavigationSubform = MyForm
End Sub
But it generates a Runtime Error '438': Object doesn't support this property or method.
Next, I tried:
Private Sub cmdCreateNewForm_Click()
Forms!MainForm.NavigationSubform.SourceObject = MyForm
End Sub
This causes the NavigationSubForm to go blank, so that ListOfForms disappears. This seems like I am on the correct track, but what do I need to do to get it to put a blank MyForm in the NavigationSubForm instead of just an empty space?
The form you have labeled as "List of Forms" appears to be what's called a continuous form, and I'm guessing it's inside a subform control located on a another form. I'm also guessing that your Create New Form button is probably located on the header section of your continuous form. I'm also making the assumption that your continuous form/subform is bound to an editable recordset/recordsource but there's no way I can tell this by looking at the screenshot.
With these assumptions in place, the code for your Create New Form button would probably be something like this:
Private Sub cmdCreateNewForm_Click()
Me.AllowAdditions = True
DoCmd.GoToRecord, , acNewRec
End Sub
If any of my assumptions above are incorrect than it's likely this code won't work as expected.
Be aware that New Records in continuous forms (and datasheet forms) always appear at the bottom of the list. I'm not aware of any easy way of making them appear anywhere else.
I am developing a program to track client information that utilizes a navigation form as a main menu that is open at all times. Many of the subforms have list boxes that need to be requeried as data is entered/changed or the users tend to think that they haven't changed the recordset and we end up with duplicate data. I can't figure out how to check if a specific subform of the navigation form is open before I run a refresh... they are all referenced as 'NavigationSubform'. So, for example, if I add a new job placement for a client, I'd like to run a requery of this listbox in the 'onclose' event to make sure they have the newest info. I can do it... Forms!navMain!NavigationSubform.Form.lstEmployment.Requery ... but it bombs if the user has changed panes on the navigation form before closing the form. This happens a lot: for example, a client interrupts while you are entering Job Placement info and you stop and enter a counseling note before going back to it, leaving the main menu sitting in the 'Clinical' directory. Is there a way to check if a specific subform is loaded within the Navigation Subform object? I've attached a screen shot in the event it helps this make sense.
Thanks in advance for any suggestions!!
Employment Screen
It has been a while but I believe you can use the isLoaded method to determine if a subform is loaded
http://msdn.microsoft.com/en-us/library/office/ff194656.aspx
hope this helps,
Brent
You can check the contents of a subform control with the source object property, for example:
forms!mainform.asubformcontrol.sourceobject
You can also get the name of the form from the form object:
forms!mainform.asubformcontrol.form.name
I am trying to hide specific columns in an Access 2007 split form through code. I need the form to check certain conditions to see whether it needs to display a column or not. I have code in the form's 'Activate' event to hide the column like this:
txtControl.ColumnHidden = True
This code works in the "Open" event, but if I hide the column on Activate, it won't display these changes until I close the form and open it again. I have tried calling the form's refresh, repaint, and requery methods, but this doesn't work. Please help!
Edit: Ideally, I need this event to occur whenever the focus switches to this form.That's why I'm using the Activate event rather than the Open event.
Try setting it in either the form's Current or Load events. You will also probably need to requery the control after setting that property: Me.TextControl.Requery Current is called every time a form's record is changed, the form is repainted or requeried. Load, as its name suggests, is called once, after the form has opened when the form loads its records. These have always been more reliable for me than using Activate, which really has to do with more the focus of the form, not really what you want.
I've had a problem like this before working in Access 2002. I was able to solve the problem with a subform by setting the subform source object equal to itself and then running the requery.
Me.SubForm.SourceObject = Me.SubForm.SourceObject
Me.SubForm.Requery
See if this technique works for your particular situation.