MS access check box on a form - database

I looked in the "similar questions" and could not locate one like I have. I'm using Access to print labels for an event and there are 200+ volunteers to whom we will mail out their event package. I'm looking for a way to show all their names (thinking on a form) AND have a check box for the "print label." Once everything I need is checked, I open a report via command button and the selected names are printed on labels. Also, is there a way to store the date / time printed, so I can use that as a "was this label printed? function. I took a crack at what it would look like using Excel (see graphic),

First, create and fill a table holding the name, perhaps some other fields, and a Yes/No field:
ID - FullName - (other fields) - PrintLabel
Then, create a continuous form using this table as source (there is a wizard for this).
Finally, modify your report to use this table as source and specify a filter:
PrintLabel = True

Related

Input field border in other color for NOT NULL fields

I would like to have the input field border in another color if the underlying field is NOT NULL.
After studying the CakePHP documentation I think I can somehow implement it with the Custom Widgets but how do I get the information if the field is NULL or NOT NULL, or does CakePHP already offer something pre-build which I didn't find?
Update:
I display all tables in the edit mode with one script. With this I want to avoid 50 edit.php scripts serving each table in the database. In this one script I generate on the fly the edit form. This means, this script is NEVER assigned to exactly one table. This is not the problem as I can parse all fields and display them properly for every special database type [date, varchar, set, int, time, ...].
Even the field description is read automatically from the table field comment which is then displayed as title tag when the mouse is moved over the ? symbol.
And now, as the next step, I would like to show a different border for a input field which is NOT NULL. This means, the different border should be shown for all fields which are displayed for the table.
I am using CakePHP 4.1.4
I found this solution:
Due to the fact the function has to evaluate the table schema in order to generate on the fly the form, the function knows which fields are NOT NULL. Then, when it creates the field with $this->Form->control(..) it adds simple in the options argument ["style" => "border: color width type"] for these fields, which are NOT NULL..
If somebody has a more elegant way, please post it as an answer so I can learn something and I'll accept it.

Power builder rtf column does not display simple text

I need to convert some datawindow text columns (PB 11.5.1 - SQL Server 2008R2 - datatype Text) to RTF.
I have 2 issues:
New data are displayed fine but the existing data do not display at
all
The RTF format popup has very limited height so the icons are half
displayed
For the first issue I did find a work around but it is far from elegant!
I append this:
{\rtf1\ansi\ansicpg1253\uc1\deff0{\fonttbl {\f0\fswiss\fcharset161\fprq2 Arial;} {\f1\fswiss\fcharset0\fprq2 Tahoma;} {\f2\froman\fcharset2\fprq2 Symbol;}} {\colortbl;\red0\green0\blue0;\red255\green255\blue255;} {\stylesheet{\s0\itap0\nowidctlpar\f0\fs24 [Normal];}{\*\cs10\additive Default Paragraph Font;}} {\*\generator TX_RTF32 13.0.501.502;} \deftab1134\paperw3240\paperh16838\margl0\margt0\margr0\margb0\widowctrl {\*\background{\shp{\*\shpinst\shpleft0\shptop0\shpright0\shpbottom0\shpfhdr0\shpbxmargin\shpbxignore\shpbymargin\shpbyignore\shpwr0\shpwrk0\shpfblwtxt1\shplid1025{\sp{\sn shapeType}{\sv 1}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}{\sp{\sn fillColor}{\sv 12506623}}{\sp{\sn fFilled}{\sv 1}}{\sp{\sn lineWidth}{\sv 0}}{\sp{\sn fLine}{\sv 0}}{\sp{\sn fBackground}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 1}}}}}\pard\itap0\nowidctlpar\plain\f1\fs20
before the text and add a } in the end.
I hope there is another way that does not include changing the actual data!
Any help appreciated
It might be a little cleaner to use the PasteRTF PowerBuilder function for existing data. Technically this doesn't solve your concern about changing data as the function probably adds the RTF tags much like you are doing manually.
As another method that might work is to try using a separate RichTextEdit control and the DataSource function. The DataSource function allows a RichTextEdit control to share data with a DataWindow and display the data in its input fields. If there are input fields in the RichTextEdit control that match the names of columns in the DataWindow, the data in the DataWindow is assigned to those input fields. I'd look at the InputFieldNamesVisible property also because it affects what is displayed.
This example from the Help File establishes the DataWindow control dw_1 as the data source for the RichTextEdit rte_1. Using a template document might be a way around your challenge of displaying data, but not actually changing it- not sure I have not used this myself.
rte_1.DataSource(dw_1)
This example inserts a document called LETTER.RTF into the RichTextEdit rte_letter (the names of the document's input fields match the columns in a DataWindow object d_emp), creates a DataStore, associates it with d_emp, and retrieves data. Then it inserts the document in rte_letter and sets up the DataStore as the data source for rte_1:
DataStore ds_empinfo
ds_empinfo = CREATE DataStore
ds_empinfo.DataObject = "d_emp"
ds_empinfo.SetTransObject(SQLCA)
ds_empinfo.Retrieve()
rte_letter.InsertDocument("LETTER.RTF", TRUE)
rte_letter.DataSource(ds_empinfo)
As far as the icon question - I am not aware of a solution for that.

How to specify PathToSubformControl for BrowseTo in access 2010

Could someone help me with BrowseTo macro plsease? I cannot figure out one of the arguments in the this macro in ACCESS 2010 which is PathToSubformControl. I have this Form called "frm_navigation":
The names of all Tab are: nav_vacancies, nav_contacts, nav_organizations etc.
The field "Organization name" in the figure will hold the name from another table tbl_organizations. However, the Tab "Organizations" (the third from left) will display all info from the table tbl_organizations.
I would like to program a button that takes me to Organization Tab and set a current record according to the name displayed in the field "Organizations name".
So far I did it via DoCmd.OpenForm but it filters out all other records and opens a new window. I tried to set BrowseTo action as follows:
DoCmd.BrowseTo acBrowseToForm, "frm_Organizations", "frm_navigation.nav_organizations", "[tbl_organizations].[PR_ID]=" & Me.cb_org_name.Value
but I've got runtime error as my PathToSubformControl is wrong. How am I supposed to specify the path? I cannot understand the structure. It's supposed to follow this pattern: MainForm1.Subform1 > Form1.Subform1 but it's not explained what is what.
Thanks
Very late reply, but...
In your code, "frm_navigation.nav_organizations" needs to specify the name of the NavigationSubForm subform control (by default it is NavigationSubForm).
Let me try to re-state your command with generic names:
DoCmd.BrowseTo acBrowseToForm, "frmToDisplayInNavSubCtl", "frmMainFormContainingNavSubFrmCtl.NavSubFrmCtl", ....criteria....
So, in short, you need to go into design view on your frm_navigation form and determine the name of the NavigationSubForm control, not the names of the navigation buttons (e.g., nav_organizations, nav_vacancies, etc.) and use that after the dot, instead of .nav_organizations (the name of the button control).

How can I get the ID of a record when it isn't mentioned on a form in Access 2007 via VBA?

I have a multiple items form which does not mention the ID of the record. I have a button for each row which, when clicked, opens up a new form containing more details.
In the past, I've added a field for the ID but made it invisible, but this seems silly - the ID is a unique field of the original query, so I should be able to access purely with code somehow.
Does anybody know how to do this? Let me know if you want more clarification.
Update
The fastest way for me to do this is to add a field in the form for the field in the query, call it the query field name, save it all and close it, then delete the field. Though of course I'd rather just be able to do Me.ID without any of that prior nonsense.
In some cases, you may have to refer to Me!ID, rather than Me.ID because the field has not been added as a property of the form (discussion: http://tek-tips.com/viewthread.cfm?qid=1127364 )
When you add the ID as as control and then delete it, it becomes a property of the form, which is why your work-around works.
If a form's record source includes a field named "ID", you can access the field's value as a property of the form:
Debug.Print Me.ID
That works without a control bound to the field.
you probably need to edit the recordsource / query.. and add that column as an available field.

Counting instances of a parameter value on an access form

I'd like to display, in the form footer of a Microsoft Access form, a count of a particular value of a field ("Category") I have tried using
=Sum(IIf([Category]="S",1,0))
as the control source for the text control in the footer, but this fails. I cannot figure out why I cannot perform this calculation on this control/field combination. I suspect it has to do with "Category" not being the control source for any control, even though it's available in the second column of my combo box.
I have performed the count on the "Appliance" field instead, and the sum function works correctly, So I'm pretty sure my general syntax and references aren't completely broken. Both underlying values are text fields.
I'd love some help with how I can get to the second parameter of the query with the Sum function?
Specifics:
ComboBox
Name is "lstAppliance". Bound Column: 1 , Row source :
SELECT qryApplianceDetails.Appliance, qryApplianceDetails.Category FROM qryApplianceDetails;
Text Box
Name is "txtCategory" , Control Source:
=Appliance.Column(1)
In case this isn't clear enough, what I'd like to see looks something like this:
Form header:
Appliance , Category
Form detail
Truck , S
Truck , L
Car , S
Bike , M
House, L
Planet , S
Form footer
Number of "S" things: 3
With this source in the footer:
=Sum(IIf([Appliance]="Truck",1,0))
Displays "2", as you would expect, but:
=Sum(IIf([Category]="S",1,0))
Displays "#error", instead of "3" as I'd expected.
I would try something simpler, but not sure if this will be too simple for what you need.
Use this expression as the control source for txtCategory:
=DCount("*", "qryApplianceDetails", "Category='S'")
Then in the form's On Current and After Update events, add this:
Me.txtCategory.Requery
In regard to the issue of using a field in the form's recordsource in an expression (or in VBA code), since A2000, things have become more difficult. It's not reliable if the field you're using has not been used as the ControlSource of a control on your form. The workaround is to create an invisible control with the field as its ControlSource.
Another way of working around that problem would be to create a control with this ControlSource:
=Val(IIf([Category]="S", 1, 0))
...then Sum() on that control.
I don't like the idea of using a DCount() as it requires a hit on the database for data that's already in the form. Secondly, if this is in a subform, the DCount() would need to be filtered not just on the Category value but also on whatever the link field is between the subform and its parent. It just gets so fussy that I'd say it's better to go with something that can be derived from the recordset already loaded in the form.

Resources