Microsoft Access - reference object on a 2 layer menu navigation control - forms

I got a form called frm_deleteFinishGoodsInventory which contains a combo box that has a afterupdate. This event works perfectly fine in a stand alone form.
When it comes to putting this form on a navigation control, I can't seem to reference the cbolotNo.
Example of a 2 layer menu navigation control
As you can see, I am in the menu Shipping (1st layer) + Delete Carton From FGI (2nd layer) -> targeting the frm_deleteFinishGoodsInventory.
I have tried multiple things, but I always end up with the same error or the program crashing since I can't reference the object.
frm_NavMenu = main navigation form
NavigationButton26 = 1st menu layer ( Shipping )
NavigationButton819 = 2nd menu layer ( Delete Carton From FGI )

Have you tried changing this to:
DoCmd.ApplyFilter , "[lotNo] = " & Me!cboLotNo

Related

How do I set size of colums in a table subform datasheet view in MS Access

I have a subform bugging me. The mainform contains buttons etc. Everytime the user close/open the form, the columns width is reset to whatever the table likes. If i open the table directly, the size is as i want. If i change it in the subform, it is not saved. (See screendump)
I would like "Phase" to stay about 2 cm width. I can enter the subform and edit the "Width" but that is only applied to the other views.
I hope you can help, Emil.
I realize this post is almost 2 years old, but I ran into the same problem and came across this post.
I am running MS Access 2013 on Windows 7 Ultimate. I did not find the solutions offered here to work for me, so, I set out to find something that would work for me before I went to VBA code. (Incidentally, I appreciate the link offered by #Patrick_Honorez in his comment on the original post because that was going to be my fall-back solution.)
Anyway, here is what worked for me and I hope perhaps it will work for others as well:
Open the parent form.
In the subform, right-click the column header
for the column for which you wish to adjust the width.
Select the “Field Width” item from the context menu.
In the “Column Width” dialog that appears in step 3, enter the desired column width in points, or, use the [Best Fit] button. Then click the [OK] button to close the dialog and return to the form.
Right-click the parent form’s border to bring up the parent form’s context menu. Click the “Save” item in the context menu.
Now close the parent form.
The next time the form is loaded, the column widths should be as set it step 4 above--at least they are for my setup.
I see this post is quite old and OP must have figured someway to tackle the issue. I came across same issue today and found solution on this link.
For anybody else having same issue, use following code (I modified the code a little because original code from the above mentioned post saves column width of only text boxes but my form has combo boxes too, column width of which was not getting saved) in close and open events of your subform and then open main form in Form View and then manually select desired widths either by mouse, by entering column width value or using best fit. Save the form and reopen to check results. That's it.
Private Sub Form_Close()
Dim ctrl As Control
For Each ctrl In Me.Controls
If (ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox) Then
SaveSetting "propertiesDBS", Me.Name, ctrl.Name, ctrl.ColumnWidth
End If
Next
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim ctrl As Control
Dim frm As Form
Dim w As Long
For Each ctrl In Me.Controls
If (ctrl.ControlType = acTextBox Or ctrl.ControlType = acComboBox) Then
w = GetSetting("propertiesDBS", Me.Name, ctrl.Name, 0)
If w <> 0 Then ctrl.ColumnWidth = w
End If
Next
End Sub
I know this is late to the party and most likely going to be the last comment anyone reads, but this can be done quite simply in MS Access 2016 - by someone like myself who has no more than 4 days experience in databasing overall and no experience with writing custom Macro's or VB Script (using only what is native to MS Access).
Here's how I did it.
Scenario - Split Form (Form + Datasheet).
Extra Recommendations:
It pays to be across all properties of every object type in your database, as a change in a field property can cause unpredictable erratic effects, which take ages to figure out why it happened and how to stop it from happening again, whilst delivering your desired outcome.
Me.Requery in your VBA script after every necessary event and also in your main form (generally the 'After Update' event is used most), and be wary that too many Me.Requery's (in unnecessary events) can also be detrimental - so too much of a good thing can be a bad thing.
Bottom Line Up Front - Modify the format of your query that is to be exported/printed.
In 'Design View' of the query you are concerned with, ensure that the fields are in the order you need them outputted in first as this is exactly how the macro will present them for export/print (example could be "Australia" then "Northern Territory" then "Town's In The Northern Half Of The State" then "Darwin" then "Suburbs In The Northern Half Of City").
Switch to 'DataSheet View' in the same query and use the top left folded over triangle looking thingy to highlight the entire data set then right click that same triangle to present an options menu. Select 'Row Height' and type in "15" (default row height in Excel).
Deselect the entire spreadsheet and this time select every column (left click the left most column, hold shift button, scroll over to the right to the far end of the data set and click the last column) and then right click one of the highlighted columns to present another menu. Select 'Field Width' and within that new pop-up menu select 'Best Fit' and then 'OK'.
(Optional - not sure if this helps or hinders but I did it for my purpose) With the columns still selected right click one of the highlighted columns again and select 'Freeze Fields'.
My scenario had buttons with macros configured to run filtered reports so I was able to check this by simply clicking any of those buttons and seeing the report formatting, which it held true to the work I had just done. I exported using another button with a macro that exports to Excel with 'Print Formatting' selected (my main form also had the datasheet view as the only thing that could be printed and was also set in 'Print' formatting.
The Excel spreadsheet opened with all row heights and column widths in a way that I could read every field/record with perfect ease and without extra modification.
This also worked for cascaded combo boxes, with the export only outputting the 'drilled down/filtered' datasheet records, in a format that required no further modifications.
Hope this helps someone, as its saved my hide! :)
Open the Main form in Design. Go to the SubForm. Click on the square at the top left of the SubForm and select 'Properties'. Right-Click the control 'Phase' and click 'Properties'.Click the 'Format' tab and select 'Width'. What do you see there? That should control the widht of control 'Phase' unless you have some overriding coding elsewhere. Input the size you want and see what happens.
Use continuous forms instead. It gives you complete control over how your subform displays.
If you open your subform directly, your property sheet menu should display automatically if the default view is "Datasheet." Click on "All" and change the "Auto Resize" property to "No." This should solve the issue and avoid the need for VBA.
This only works when you open the subform separately. So if you want the changes to be reflected within your main form, you'll have to close it and switch back and forth.
Super annoying by default.
It seems to work as one would expect of you set the view mode to layout view. Drag column widths as needed and save. Go back to form view and it works. It's really dumb it doesn't work the same way in form view our design view.
In Access 365, open main form, right-click sub-form datasheet columns that need width adjustment, use the Field Width to adjust, click on border of main form to select Layout view, and save changes.
Open subform in datasheet view (by double click on subform in the left pannel)
Resize columns as you want by dragging or by right-click the column header for the column for which you wish to adjust the width and select the “Field Width” item from the context menu.
Right-click the subform border to bring up the context menu. Click the “Save” item in the context menu.
Either open the Main Form in Layout View or directly open your Subform in Datasheet View. Right Click on the Field Header, select Field Width, and enter the desired width. Save. Bewm.
My solution (Access 2016) was to create the main & subform, recreate the subform on its own using form wizard and set it up the way I want it, rename the original subform to something else, and finally rename the recreated subform to the original form name. Open the main form and the subform should be laid out the way you want it. You can then delete the original subform you renamed.

A master/slave panel in Extjs 5 MVC

I'm using Extjs5.1 powered by a MVC oriented code style.
I've got a main view which inherits from Ext.panel.Panel with a border layout.
On the east region, there's a grid with a store containing several records (or "models", I don't really know what terminology I should use here). (the "master grid")
On the center region, there is another view that inherits from a Ext.form.Panel and which is supposed to display the selected item of the grid . (the "slave form")
My goal is to refresh the "slave form" with the selected record of the "master grid".
The only way I found to "communicate" between the grid and the form is to execute a fireEvent('selectRecord', ...) from the main view controller and to listen to him inside the form view controller, but it seems odd as the form view is a child item of the main view.
Is there a more common way to do that?
By corrolary, is it a fine practice to make a view call functions of another view directly or should I make only their respective controllers interact?
What I usually do and I believe is the most common approach for this, is having a selectionchange event listener, that updates your form like this:
listeners : {
selectionchange: function(model, records) {
var rec = records[0];
if (rec) {
formpanel.getForm().loadRecord(rec);
}
}
}
for this to work, the name property of your form fields must match the name of the fields in the grid store model.
There is an example of this here: http://dev.sencha.com/extjs/5.1.0/examples/kitchensink/#form-grid

how to hide and unhide authoerable tabs depending upon value selected from a drop down in CQ5

i am trying to create a footer component in CQ5, where i have 4 columns & all are autherable.
But we have to make no of columns autherable too i.e based on a value selected form a dropdown we have to open those many tabs for authoring those many columns only.
i have created a dropdown and have a maximum range of 6 columns. i know that i have to configure a listener for this purpose but don't know how . Requirement is like if i select 3 from the drop down then 3 tabs should come to author 3 columns
pls help me , i am middle of something very important.i need the solution very early too as i have to finish the job as soon as possible
I might be late for this by now but in case you still need it:
You need to add a listener node before closing your drop-down element:
<listeners
jcr:primaryType="nt:unstructured"
loadcontent="function(box){ //here you also need to handle the hide/unhide when the panel loads for the first time. Use this.getValue() to retrive the intial value }"
selectionchanged="function(box, value) {
for(var c=1;c<=value;c++){
this.findParentByType('tabpanel').unhideTabStripItem("tab"+c); // You need to handle the opposite with hideTabStripItem("tab"+c);
}
}"/>
Then on both "loadcontent" and "selectionchange" (these are events on your drop-down) grab the current selected value and use it to hide/unhide the tabs. In this case the tabs would be named "tab1", "tab2", etc, make sure you get the names right.
The ExtJS in the events is finding the "tabpanel" container for the whole dialog, and then hiding/unhiding based on name. You could also set to enable/disable using the methods ".enable()" and ".setDisabled(true)". Just make sure you get the reference to the tab first if you want to do this (something like ".getComponent(tabName).enable()").
I didn't test this specific code, I couldn't find my actual example from my code base but this should take you in the right direction.

Create TAB and create textboxes that take data in the TAB-page

I am working in PyQt. The existing code (extremely long and sources almost all the org.'s s/w) has sections which is responsible for creating tabs and textboxes. But, being a newbie to PyQt, I am not clear on how it all works. For my part, I need to do the following:
(1) Create a TAB titled 'xyz' within the row of all the other tabs.
(2) Create 6 textboxes with individual labels in the page displyed by the created TAB where the user can enter data and save it.
These are the two immediate problems I have to deal with now. Later,
The data entered in the textboxes will replace the data in bar-graphs (in another window) as soon as the data in the textboxes is entered and saved. This is to be done afterwards but first I need to solve the 2 issues listed above. The imports are all there in the (longish) code and I have to insert my new code within that code - perhaps by creating a new class. Can you help? Thanks. And, please let me know if you need any information to work on this.
EDIT::::::::::: Have inserted the image below. As you can see, at the top of the left pane, there are multiple tabs in a row (all made in PyQt). I need to create a tab like the last one (here, titled-Incentives) with a blank page like the one shown below the tab. Within the page, I need to create 2 sets of textboxes, 3 textboxes in each set with labels for the set(s) and the individual textboxes. Data entered in the boxes will be integers(20) and the data will then go on to populate/update a dynamic stacked bar graph. At this point, I want to ask another question. When the data updates the graph, should it be first saved in the DB (the DB which is primarily responsible for the initial figures in the graph) and then routed to the graph or should the data update the graph directly, bypassing the DB and if so, won't the graph revert to its earlier values and forget the data from the textboxes once it is reset. Thank you.
OK. Here you have a code that you can use as a starting point for your own development. It creates a QTabWidget with two tabs. The "Tab 1" tab contains a vertical layout with two groupboxes. Groupboxes contain labels and textboxes arranged in a grid. The other tab is empty.
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class MyMainWindow(QMainWindow):
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
# Create the tabbed widget
self.central = QTabWidget(self)
self.setCentralWidget(self.central)
# Create a new tab
self.tab1 = QWidget()
# Tab has a vertical layout
self.vbox = QVBoxLayout(self.tab1)
# Tab children: two groups containing a grid of labels and textboxes
self.group1 = QGroupBox("Group 1")
self.textBox1 = QLineEdit(self.group1)
self.textBox2 = QLineEdit(self.group1)
self.fillGroup(self.group1, self.textBox1, self.textBox2)
self.group2 = QGroupBox("Group 2")
self.textBox3 = QLineEdit(self.group2)
self.textBox4 = QLineEdit(self.group2)
self.fillGroup(self.group2, self.textBox3, self.textBox4)
# Add tab children to the tab layout
self.vbox.addWidget(self.group1)
self.vbox.addWidget(self.group2)
# Append tab to the tabbed widget
self.central.addTab(self.tab1, "Tab 1")
# Create a new tab and append it to the tabbed widget
self.tab2 = QWidget()
self.central.addTab(self.tab2, "Tab 2")
def fillGroup(self, group, box1, box2) :
"""Arrange the groupbox content in a grid layout"""
grid = QGridLayout(group)
label1 = QLabel("Input 1:", group)
grid.addWidget(label1, 0, 0)
grid.addWidget(box1, 0, 1)
label2 = QLabel("Input 2:", self.group1)
grid.addWidget(label2, 1, 0)
grid.addWidget(box2, 1, 1)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
ui = MyMainWindow()
ui.show()
sys.exit(app.exec_())
Please notice that for my convenience I've used a QMainWindow as a parent for the tabbed widget. Obiously you can use other widgets as parent if you need it.
Hope it helps.

Referring to variables and functions in different scripts

I think this question has been asked, but I've searched through Google and here, and still a bit confused on how it works.
I have two scripts, CS1.coffee and CS2.coffee, CS1 is what is loaded with the main page, and has a button on it. When the button is pressed a window appears and CS2 is run. However, I want to refer to variables that exist in CS1 from methods in CS2.
In other terms,
Main page loads, calls CS1 (which has button logic)
Button is pressed
A new KendoWindow appears which calls CS2 (this window displays data that is taken from variables in CS1)
Sample Code:
CS1.coffee
root = export ? this
root.number = 42
$("#winButton").click=->
//new kendoWindow appears, with content being a separate html containing CS2 scripts
root.testFunc =->
alert 'I was called'
CS2.coffee
root = export ? this
answer = root.number
$("#testButton").click =->
root.testFunc