I have a small table 2*2. I show the values of the form in a continues form. Suppose, it show the values in the form as below
fname lname
----- ------
adam jones
terry jonas
For simplicity I kept the table size small. But basically it is 10*10 size table. Anyway, what I want is that, the names that show on the form should be editable. So after showing the form above, I should be able to edit all the names adam, jones, terry, jonas. After editing the names, if user click on update button then all the names in the database table should be updated.
I don't understand how to do this. This is a continuous form. How can I keep track which names are being changed on the form? Or should I update the whole table? Or if I make it single form without being continuous will it help? Please give me some insight so that I know how to proceed.
A continuous form is by definition a bound form, i.e. it is directly connected to a table or query. If you edit a row, and move to another row, or close the form etc., the edited record is saved automatically.
This is standard Access functionality, and you don't need any code (or a "Update" button) for it.
If you want to have more control over the saving of records, you need a different approach. But you should have a real reason for it, otherwise you are just creating useless code.
E.g. you can make the continuous form read-only, and on double-click open an unbound single form that loads the values of the current row, and is editable. There you can have a "Update" button that saves the values to the table, and a "Cancel" button that discards the changes.
Or if you want to edit on the continuous form, you can copy the whole table to a temporary table, base your edit form on that, and on "Update" copy the temporary table back to the actual table.
Related
I have several (many, 30+) tables of values ready for use in comboboxes on various forms. I want users to be able to add values to these tables in case they need an additional value while filling out a form, but I do not want to create 30+ identical forms (one for each table) to make edits. So, I have a form where I can select one of the tables from a combobox and then open another continuous form that will eventually be used to show and edit the values in the table I selected. What I can't figure out is how to link the continuous form text fields to the table I selected in the previous form. I need to be able to set the textBox control source to something like [Tables]![[Forms]![FormToSelectWhichTableToEdit]![Combo0]]![DropdownValues], but I have the wrong syntax or something.
I have frmMain that has a number of subforms that are contained in several tabs on tab control on frmMain. I have subForm3 on one of the tabs of frmMain. subForm3 has a textbox control called tbxNote. tbxNote requires one user to make changes to the note based on feedback from a supervisor that is shown in a separate, non-modal popup form called frmFloater that appears above frmMain so that the supervisor's note shown in the non-modal form can be seen while tbxNote in frmMain.subForm3 is being editted.
Now, both frmMain and frmFloater can change the data in the same table. I understand that this is what is causing the write conflict error I am receiving.
So, I want to be able to trigger a save of the data in subForm3 when the user exits tbxNote, for example, the user exits by clicking frmFloater or a control in frmFloater. And, I want to trigger a save of the data in frmFloater when I exit frmFloater or click a control in frmMain.
The problem I am running into is that I cannot find an event that triggers when I leave frmMain or when I enter frmFloater; nor can I find an event when I leave frmFloater or when I enter frmMain.
I have tried the following events for frmMain (and also in frmFloater), none of which trigger when the user leaves frmMain (e.g., by clicking into frmFloater) nor do they trigger when the user leaves frmFloater (e.g., by clicking into frmMain):
On Deactivate
On Activate
On Current
On Click
On Got Focus
On Lost Focus
How can I detect switching to a different form so that I can save out the data in the first form before handing control over to the 2nd form?
If there are 2 forms showing 1 record, you will always run into problems. I would look at separating the record into 2 tables and creating a relationship between the tables to prevent corruptions of records. For example:
Table 1 will hold the main information of the record being viewed
Table 2 will hold the supervisor notes
The relationship between the tables will be either a 1 to 1 (if you want a note to be a single record and all updates the current note) or a 1 to many (if you want multiple records with multiple notes
be sure to check "enforce referential integrity", "Cascade Updating", and "Cascade Deleting". Otherwise you will have orphan records.
To answer your question, it cannot be done with the current setup. If employee A is editing the record on frmMain and a supervisor opens frmFloater and begins adding notes. You just corrupted the record... Reason being is, you cannot have the front end the employee has save the record the front end the supervisor has. only their machine can save the record the specific person has accessed. make sense?
There is another solution, and that would be making frmFloater an unbound form. There is quite a bit of programming involved to accomplish this, but once I made all my forms in my Access Databases unbound and all the controls unbound, I never had a corrupted record incident again. But this requires a button building the query before opening the form, open the form, then take the values from the query and place the values in the corresponding textbox on your form, then close the query. This will give you a snapshot view of the record on the table without being bound to it. Your button/afterupdate event can then run an update query on the record without locking it.
Let me know if this helped or if this did not make sense. If it didn't make sense, I'll try to explain a little better.
I have the following situation:
I have a many to many relationship.
For example an Employee Table, an Course table, and an relation-table inbetween.
Now I want that the user can select out of the course table his courses in a dialog form.
That means that the underlying table for my continous form inside the dialog is the course table.
I want a checkbox in every row which indicates if the course is selected or not.
As I read it is not possible, to add an unbound checkbox, because they are just copies, and a select click would select all of them.
The solution would be to add an yes/no field to the underlying table courses.
But here I have the problem as I understand the matter, because I have several users using the database at the same time, that the underlying table will be updated if I click one checkbox and this update will select the value for all users which are using the dialog form concurrently, what I dont want.
So my question is, is there another solution to get a working checkbox per row in a multi user access database.
There are two solutions which I could imagine:
1) The underlying table will be the relation table and in this every possible combination between employee and course will be saved together with a yes/no field. (but that would be from a data view point quite horrible)
2) If the changes to a checkbox would not be directly written back to the database table, I could discard them on saving and manually insert the relation records in the relation table. (Is that possible?)
Thanks for any solution proposals
I see two good approaches:
1) This assumes that your database is split in a network backend + each user has a local frontend. This is the recommended setup for multi-user.
The frontend has a local table with Course_ID and a yes/no column.
A join of this local table with the Course table is the recordsource for your continuous form.
On loading, you copy the course ids into the local table, and set the existing relations to True.
On saving, you update the relation table.
2) Use a ListView control instead of a continuous form. It has inbuilt checkboxes. Loading and saving is done with a VBA loop.
Based on your description I assume your form has a LEFT/RIGHT JOIN in its data source where some ID field is null if the specific Course/Employee combination does not exists in your relation table. Let's call it LinkID. Then your checkbox should be something like =NOT ISNULL(LinkID). While you will not be able to use the OnClick event for the user to check/uncheck this way, you can use the onMouseDown event to see if the user clicked the checkbox and take action accordingly.
That way you don't need an "all combinations" relations table, no temporary table and no Yes/No field. If a record with the Course/Employee combination exists the box is checked, if it does not exists, it is not checked. Adding and removing courses is done by adding and deleting records from the relation table.
Have a look at this How to use unbound checkbox in a Continuous Subform - MS Access. A class that binds an unbound checkbox. Better than listbox, because you have a form with all its benefits (sort, filter, edit, append).
I am sincerely sorry if this question has been asked before, however with my limited knowledge of using Microsoft Access forms I am having an issue that is likely a very simple fix.
At the moment I am trying to create a form that will allow me to post data into an intersection table using combo boxes, the purpose is to create a relation between Clients and Project Numbers, these are intended on being a Many-to-Many relationship.
Relation Example
To begin with one issue I am running into is that when I use the intersection table to select a unique Client Name I get multiple entries from the drop down menu when there are multiple items in the intersecting table.
Form Example
The second part of my issue is that I am unsure how to post data to the intersecting table once the dropdown selections have been made.
Any help is greatly appreciated, and I thank everyone for their time.
The first part is to create a form in which you find, and edit data in the main client table.
This form will ONLY be based on the single main client table.
You perhaps ALREADY have a nice form to edit the client table anyway. I mean, how else will users find and edit a client anyway? So this issue and problem will LONG be dealt with before you do anything else of use in the application.
The form based on this single table might look like this:
Ok, now close the above, and create a second form to allow adding some choices of favorite colors (or in your case ClientContract). So the form will be based on this child table.
Again, like the first form, this form is based on ONE table.
Make this form continues, so click on ClientContract table, and then from ribbon choose multiple items form from the ribbon. It will look like this:
Of course we don’t want the user to have to manually type in the color (or project in your case), so we drop in a combo box from the ribbon and use the wizard. MAKE sure the first column of this combo is the PK of the ProjectNumber table, but FOR EASE of reading and selection, include ProjectNumber and Project Description columns in that comb box. NOTE in above how I also had added that combo box.
Assuming you closed and saved this form.
Now open our first main client form in design mode, and drag + drop in the continues second form we just created onto this form. The resulting form will look like this:
Access will automatic set up he customer_ID for us (because it is a sub form attached to the main form that only displays the one main record).
Once the above works, then again close the lot, and open up our continues form in design mode and remove all the extra junk.
(leaving ONLY the combo box).
The result is this:
We are rebuilding an asset database with Access 2013. We have 1 table with a Primary Key (Serial number of asset), and 22 other fields. We're designing a form to be used with the table so that we are not manually editing the table. The 'Status:' field explained later does not exist in the table; it is a user friendly way to show if the record exists or not.
The end goal is to have a form that will two cases. A user will enter a PK and hit the tab key. Then:
If the PK exists, it will pull the info from the other 22 fields and put them into the fields on the form (1:1) and update 'Status:' to 'Existing'.
If the PK does not exist, it will change the 'Status:' to 'New' and make all of the fields blank.
Most of the fields on the form will be Combo boxes. There will be a couple text fields and 1 date/time field.
Once a user is done with the form and has made any necessary changes, there will be a 'Save' button at the bottom that will write whatever is in the forms to the row indicated by the PK.
I have found partial solutions with the LostFocus() event in Access 2013 on the PK field of the form. I have little experience with MS Access, moderate experience with DBA, and no experience with VBA programming. I'm sure this solution can be done, my question is: can it be solved in a way other than hard coding the solutions? I also looked around for form building, but I couldn't find anything that worked how we need it so if there is a tool that can accomplish this, that is acceptable.
You might consider a form that contains a subform. Basically, you would design a form that has your PK input box and a subform. When the user hits tab (or a "Search" button), a query would run to search the table and display that record in the subform, or you could insert a new record if not. You may need to use a few queries and macros to link it all together, but it can be done code-free.