I am trying to create what I think is a simple access Database. Problem is that I am new to using access but familiar with programming and very familiar with working in Excel. I can technically and have already done the task in excel but what I really like about Access is the Forms. I would essentially like a user to use the form as they would my Excel document but since they would have limited control, there would be less room to mess up the process.
Anyways what I am trying to do is populate a field in a table with a number. However this number signifies a severity (e.g. 1 for low 10 for high). Each severity has a "map" or "gauge" that explains what the number means in severity (e.g. 1 - will not happen, 2 - rarely happens, 3 - sometimes happens, 4 - happens, 5 - always happens). What I would like to do is to have the user see from a dropdown list the number and associated severity meaning. Then what I would like to stay once selected is only the number.
Example case:
User wants to say that something sometimes happens. User clicks on the drop down list and sees this menu:
1 - will not happen
2 - rarely happens
3 - sometimes happens
4 - happens
5 - always happens
They click on the "3 - sometimes happens". Then what they see in the field that they have just edited "3".
I think this should be possible but I am unsure on how I would even go about this. I have only started with tables, I have not made queries or forms yet. I would eventually like the user to do this all on a form so that way they have limited access. For now I am simply trying to populate a table the way I think it should be made.
The best way to do something like this is to use a value list and then display two columns in the drop down but show only one in the combo box.
Step 1
Go to the Data tab of the properties. Set the combo box Row Source Type to Value List and then follow the below example for what to put into the Row Source:
1;"Will not happen";2;"Rarely";3;"Sometimes"; etc
Make sure the Bound Column is set to 1
Step 2
Then go to the Format tab and set the Column Count to 2. Set the Column Widths below it to 1,3 or whatever size suits your system the best.
If you want to use data from a table instead of a value list it's a simple matter of writing a query to select the two columns containing the number and info like below:
SELECT [Severity], [SeverityMessage] FROM TBL_SEVERITY
To use this simply replace Severity and SeverityMessage with the relevant column names in your table and TBL_SEVERITY with the name of the table. Then place this line into the Row Source and change Row Source Type to Table/Query
That should now be you set up with what you're looking for.
Related
I have two tables, A and B. I always know that table B is going to consist of a smaller number of entries. For the sake of argument, lets say that table A contains 5 entries and table B contains 2 entries. I always know that table B is going to consist of a smaller number of entries.
I want to have a form display the difference in the size of the two tables within a textbox. So in this case it should display a value of 3.
I have never used VBA before, and I am a bit confused on how to actually get the textbox to display this. I tried setting up a "before update" script, but I have had no luck. If someone could help me out, that be great.
In a form, use below expression to textbox control source.
=DCount("*","[Table1]")-DCount("*","[Table2]")
I've run into a bit of a snag with a project I'm working on, and being new to Access I don't know if what I want to do is possible without VBA. I've looked around but all I can find are answers related to showing multiple columns, not controlling multiple fields in my DB.
To paint a picture I have a mapping system set up in my DB to help me distinguish the name and type of data is held in a table.
The setup is as follows:
-Data table is "LineItems" with an ID and the line data (think typical excel format)
-Mapping table is "LineItem_Mapper" with LineItem_ID, DataType, and Entity_ID
-A helper table "Data_Type" with ID and Name
-two "Entity" tables with differing properties both have ID and Name
The reason for the split is on data type is that the two types of data behave differently. One type has a parent child relation, and the other is a standalone row. I want to preserve this structure in my DB and feel I have done so with this mapping.
Now, on to the issue I'm running into. In my Access data entry form I want to use a combo box, as the options a user may chose for each line when entering are finite. However, this combo box is affecting the Mapping table above. I have been able to populate the box with my desired list with a custom query built from my 2 entity tables, but I don't know how to get Access to create or update the Mapping table using this box.
what I want to happen is when I chose something in the box, a line is created (or changed) in the mapping table with all 3 columns being populated. first the LineItem_ID for the line I am populating, and then the DataType and Entity ID to reflect the proper mapping.
Can Access do this on its own? Or do I need to do this with VBA?
As requested by the OP converting my commend as an answer (with a little bit more detail):
By far your best option is to use VBA. I doubt there is another way and even if there is it would be so convoluted it would be unworkable and unmanageable.
This should get you started:
In the combo box properties go tot the events tab and in After Update or On Change (look up the difference between the two events to see which behavior you prefer) click the down arrow and select [Event Procedure], then click on the … button. This will create a VBA module for you complete with the function that runs when the selected event is triggered.
You can use DoCmd.RunSQL "[Access SQL INSERT statement]" to add records to tables.
You can use Me.[MyComboBoxName] to get the current value of the combo box. Similarly the value of anything else in your active form.
You can use DLookup to get the value of any record in your tables.
Hopefully these will give you a relatively quick start.
I am designing a form at work where I need to be able to set "Properties" for a large number of (accounting) "structures". I have a "Value" field where the user enters the value that property must take and then I have 1 column for every structure where the user must be able to check / uncheck each property for each structure. Also, I need to be able to suggest checkbox values (aka mapping of properties to structures) to the user so that he/she doesn't have to manually click all the checkboxes that will always need to be ticked. Finally, the number of properties (rows) and the number of structures (columns) should not be assumed to be fixed though I don't want the user to be able to modify it himself. I just want it so that a dev (probably me) doesn't have a hard time adding or removing structures.
For now I have used a local table where each structure is a column and I have hardcoded my properties (which is good). However, I am not sure that using a local table is good design. We normally avoid having forms and tables in the same Access DB to separate forms and data. Also, I'm wondering if there is an elegant solution that I am missing. There will be at least 10-15 structures and 11 properties, that would make 110 (11*10) checkboxes to handle so I cannot do it manually (i.e. create 110 checkboxes and check 110 values everytime...).
Here you can see what that part of the form looks like for now.
I know this will be a chattier question but I really need a design check on this so here are a few questions that I try to make as general and objective as possible:
In Access, how is it possible to create a matrix of controls where 1 column contains a fixed (but changeable by a dev) number of properties, a "value" field that can take text and then 10+ columns with Yes/No values ?
Is it possible to do it without a local table ?
VBA is perfectly admissible.
Thanks.
In Access, how is it possible to create a matrix of controls where 1 column contains a fixed (but changeable by a dev) number of properties, a "value" field that can take text and then 10+ columns with Yes/No values ?
I've never seen any VBA code that does what you describe. VB6 allowed the creation of "control arrays" to logically group controls (and work around some limitations on the number of controls on a form), but I've never seen that mentioned for VBA.
Is it possible to do it without a local table?
Is it possible? Maybe, since you can modify a form via code by opening it in Design View and using CreateControl() to add controls.
Is it practical? Probably not, because the "Access Specifications" section of Access Help mentions the following limit...
"Number of controls and sections that you can add over the lifetime of the form or report: 754"
..so it sounds like code that repeatedly modifies a form could very well break after a while.
My recommendation would be to create a temporary table, use it, and then discard it. If you're worried about front-end bloat then you could create the temporary table in a temporary .accdb file and then link to it.
Maybe I'm missing something, but it seems pretty easy to me.
Make each structure a record.
Then in another table, make each property a record with a 1-many relationship with the structure table. So, each structure will have many properties.
Then a form based on the structure with a sub-form based on it's properties.
Default property values can be set in the table structure.
And of course the tables can be linked from another DB.
In Access, how is it possible to create a matrix of controls where 1 column contains a fixed (but changeable by a dev) number of properties, a "value" field that can take text and then 10+ columns with Yes/No values?
I'm still not certain why you want multiple bits/booleans in a single column, but you might be able to utilize bit logic and long integer column. VBA does something like this with its constants. For instance, in a MsgBox, you make your type = vbCritical + vbYesNo. Its result is in an integer value that VBA interprets to make a Critcal MsgBox with only a Yes and a No button. The reason this works is because the value of each constant is so distinct that any summation with like constants results in a unique value that can be de-parsed. It's fairly elegant from a user perspective, but I'd hate to do the math on the back-end to make such a function work.
It might be better to maintain a separate table of available properties and/or property sets and build / maintain your property sheet that way. You could assign property sets as well as individual properties to particular controls. You could also specify in either table whether there is a default value for that property and/or what that value is.
It is also likely that you do not need that many bits. I'd be happy to narrow my answer to your situation if you could update your question with more detail regarding the nature of your bit need(s).
Is it possible to do it without a local table?
You might be able to create a DAO.Recordset dynamically in Access.
It might be better to adjust your properties table(s) (see above) to be a permanent table in one of your databases rather than re-populating the same data every time.
You could take more of a master/detail approach, combining your bit fields into a string description describing the boxes which are checked.
For example, if you have a structure named 'structure1', value 100, and 5 condition bits set, you could have one string column with text 'cond1, cond2, cond7, cond8, cond9' and then another button allowing them to modify that set of conditions for that single structure.
You'd have fewer checkboxes, anyways.
The only thing I can think of equivalent to 'a matrix of controls where 1 column contains a fixed (but changeable by a dev) number of properties' is an editable query result set.
You'll need a table for your structure -> default conditions set, if nothing else, but it doesn't have to be in the same db as the front end.
HTH
I am trying to design a form where the user can search records to filter a report. The user must be able to select many values from a particular field (multivalued field). I understand I can use a list box, but the field has a total of 3,000 records and cycling through is too much. I just want to know what other ways I can let the user insert multiple values?
I have these ideas, but maybe you guys have another better way:
Creating multiple combo boxes and keep them hidden until the user hits an “add” button, but this limits me to the amount of values I can have. If I have 10 hidden combo boxes I can only enter a total of 11 (10 hidden plus the original visible) values.
Is it possible to have a temporary data grid where the user just enters the values.
Then comes the problem of getting this into the SQL Record Source. I am thinking of the SQL IN clause.
Any help or ideas, will be greatly appreciated.
I think that you should create Comboboxes where values from next combo are dynamically populated when value in previous Combo has been changed so that way you can create hierarchy of values to select.
I've done something similar for a few different applications in slightly different ways. Basically, I present the user with a table, allow them to right-click > filter (the same could be accomplished by providing a filter textbox for each corresponding field in the table you want to allow filtering on... in your case it sounds like you only need one). The filter box allows them to use 'and' and 'or' along with the actual text of what they're looking for. Then they click a button that opens the report and fills the report's filter field with whatever filter they had applied.
Of course, this assumes the user is familiar with the data they're filtering, and requires a bit of training, but for me it was a simpler alternative than displaying a list with a bajillion entries in it. Your mileage of course may vary :)
I am new to Access programming and am trying to determine the correct way to bind unbound textbox controls for each row in a continuous form.
As an example:
Continuous Form to display a list of invoices from an Invoice table.
Table called InvoiceItems which contains equipment, rates and hours.
I need to have a form that has a row containing invoices with a column for all available equipment types.
I was planning on having unbound textboxes for each equipment type and then when each Invoice row is loaded, hook into something like an OnRowDataBound where I could dynamically populates the equipment textboxes with the appropriate data from the InvoiceItems table.
Example:
Tables:
Invoice: InvoiceID, Date
[1, 4/10/2011]
InvoiceItems: EquipmentID, Rate, Hours
[2, 40, 1]
[3, 20, 3]
Result:
InvoiceID | Date | Shovel | Plow | DumpTruck
==================================================
1 5/10/2011 3 1 0
2 2/11/2011 1 0 1
Then each textbox control would hook into the onDirty event to update the appropriate InvoiceItem line item.
You won't be able to do this in a continuous form or a datasheet view form since changing the ControlSource property on one row affects all rows.
It's unclear to my why you would even need this option but it sounds like your data/tables might not be designed properly or properly normalized. Usually I would build my tables so that EquipType is a value you can change to show what type of equipment this row is. It appears that somehow you are using different fields for each different equipment type.
Assuming that you insist on using your current design, you could possibly cobble together a solution using Union queries but your recordset will not be updateable.
Another suggestion is to make several different textboxes on your form and change the visible property on the fly. However, this is fraught with problems because you will only be showing one of them at a time on all rows. Furthermore, you'll have to show the correct one when they move to the next record but how are you going to determine which is the correct one to show?
Judging by what you've written, you must have experience programming in .Net. Access is a different beast and it works quite well if you play by its rules. Trying to get around some standard Access behavior or design will usually result in frustration for both the programmer and the user. I think this is a case where you will need to evaluate what you're trying to do and I recommend you start by making sure your table architecture is solid. Perhaps you've actually over-normalized and will need to go back and undo some of your normalization.