I have a form linked to a table. I am trying to use the me.dirty function to see if the user changed anything. For now I put the code msgbox(me.dirty) in the form close button to determine what is happening. When some fields are changed i get true others i get false. For now I am only changing one field at a time. I have determined that if I look at the table before I close the form, if the table matches the form me.dirty is false. if not then me.dirty is true. this makes sense I dirty=true when the form does not match the table.
What I cannot figure out is why some field match the table and others do not until the form is closed. For example I have two check boxes one is always matching the table as soon as i check or uncheck it and dirty = false. The other one does not change the table until I close the form and dirty=true. Iv'e looked at all the properties of the two check boxes and they are the same.
I also have two drop downs that give me dirty=true and two text boxes that always give me dirty = false. (both cases when the field is changed.)
Any help would be appreciated as I am stumped right now.
OK I figured it out on my own. The ones where me.dirty=false had an event after update that put focus on a subform, this updated the table and then when clicked the button to run me.dirty, it was false.
Related
I have a form, the form is bound to a query which returns only one field. On that form is one combo box, bound to the field from the query, a subform object and some other unimportant stuff. The Master-Child relationship between the Form and Subform is set to that same field. The intent is that dropping down the combo box allows me to add information on the subform pertaining to that record in the combobox (it's a list of classes in a school, for context). This is done through a form and subform as I have various different tasks that need to be done for each class - the intent is to be able to select a class on the main form and then use command buttons on it to select which subform is opened depending on which task I wish to perform.
However, the Combo box appears to be trying to update a table - I'm not sure which one as the error message isn't specific:
The changes you requested to the table were not successful because
they would create duplicate values in the index, primary key or
relationship. Change the data in the field or fields that contain
duplicate data, remove the index or redefine the index to allow
duplicate values and try again
appears if I select any value other than the first one from the combo box and then click in the first text box on the subform. However, I can click in the subform with the first entry in the combo box selected and add data successfully, I've checked and it is appearing in the underlying tables.
It seems to me, as a relative novice in Access, that the combo box is attempting to update the underlying data source when it is changed, though it has no macros. I would assume there are items in the properties of the form or the combobox that prevent that from happening but I can't find them. That is just a guess as to what's happening, though, and I could be wrong.
It's possible that this is related to this question but I could be mistaken there as well. Regardless, the Form shouldn't be able to update/edit/add records but if I set Allow Edits in its properties to "No" I am unable to actually select a value from the combobox - I have set the other "Allow" properties to "No" without a problem.
If you change anything in the main form and then click on the subform then Access will try to save the data in the main form automatically. Maybe you can try to temporally exchange the combo box with a text field for testing. That should help you to clarify the problem.
I have question about Lotus Note. I have form: http://i.stack.imgur.com/YWii6.jpg
In this form I need create bottom. With this buttom user can add new row with input field in this row to existing table. I find that kind of lotusscript from:
http://www-01.ibm.com/support/knowledgecenter/SSVRGU_9.0.1/com.ibm.designer.domino.main.doc/H_EXAMPLES_ADDROW_METHOD_RTTABLE.html
But when I this script copied to this form, I get error "Object variable no set"
Then I tried this solotion:
LotusNotes 8.5 - Adding a row to a table with a button
And I again get the same error.
Can anybody tell me please, how I can create new row and input field in this row, when I pressed buttom "Add row"?
You can't make a table with a dynamic amount of rows in a Lotus Notes Form. There are two common ways to solve this:
Use child-documents; one document for each row; and show these documents using an embedded view. This is the most elegant imho.
Create a large, fixed-elements table, and hide the rows that are not needed (for instance, by checking the presence of an input in the preceding row. This is OK for small amounts of row, but performance starts getting bad if you have too many rows.
It seems you are a bit confused as to the difference between a form (your picture) and a document (the code you link). Also, you definitely need to understand the meaning of "Object variable not set", which is the most common error when you use Lotusscript.
Anyhow, where to go from here depends on how you plan using the data once it is input. Will it be edited ? Will each row need to be handled as a separate record ?
I have a form in Access where I have 2 unbound multi-select listboxes, with some code to move items between them.
Each of the fields in the table which are shown in the listboxes are boolean values - if the value is true then the name of that field shows up in lstSelected, and if false shows up in lstUnselected.
The listboxes have a RowSourceType of Value List, and the value list is generated programatically by looking at the underlying record and constructing a string with the field names where the boolean values are true for lstSelected and False for lstUnselected.
On the form I have two buttons, cmdMoveToSelected and cmdMoveToUnselected. When I click on cmdMoveToSelected it changes the boolean value of the underlying field for any selected items in the lstUnselected listbox from false to true by executing an SQL string, then rebuilds the value lists for both of the listboxes.
I have all of this working just fine. If I do a me.lstUnwanted.requery and a me.lstwanted.requery then everything moves and shows up correctly, and the underlying fields are edited correctly, BUT when I click on anything else on the form I get the error:
The data has been changed.
Another user edited this record and saved the changes before you attempted to save your changes.
Re-edit the record.
Now I've found a way around this (jobDetailsID is the primary key of the record being dealt with):
Dim intCurID as Integer
intCurID = Me.JobDetailsID
Me.Form.Requery
Me.Recordset.FindFirst "JobDetailsID = " & curID
This requeries the form and then moves back to the current record, and this gets rid of the error, however it causes there to be a delay and the form to flicker while it opens back at the first record, changes back to the correct record and repopulates the list boxes.
Is there a way to do away with this error, or get it to trigger programmatically so I can catch it by turning the warnings off via vba?
Thanks in advance.
Maybe it helps not to bind the form to the table being altered by cmdMoveToSelected, but to a query that doesn't contain all the boolean fields. If cmdMoveToSelected alters one or more boolean fields, the record is changed, but the query result isn't. Not sure if it's sound though.
It also sounds a bit like a design problem rather than a form problem, storing options in boolean fields instead of into a related table.
Probably the best solution would be to not directly update the current record in the table while the Form is dirty. Instead, update the values of the fields within the form itself (Me!FieldName) as the items are moved from one List Box to the other, and let the form write those values back to the table as usual.
I seem to have fixed it, though the fix doesn't make a great deal of sense to me.
I added in a Me.Refresh to the button click code, after I had requeried the two listboxes and it appears to have stopped the message from coming up. However this only works when I have the JobDetailsID textbox visible on the form (though I expect this is arbitrary and any field-linked textbox would work).
Can anybody explain to me why this works? I'd like to understand fully when to use requery, refresh etc
I've had this sort of thing happen when I've left the form RowSource query hanging in place after converting the controls to unbound textboxes, etc. The general Form rowsource query (to bring in all fields I might possibly end up using) provides me with a query-list identical to the table fieldnames, making it simple to select them for control-names as needed. Works fine, but you have to remove the form rowsource query after all the names are matched-up. (After which DLookup and BeforeUpdate works for getting and storing values and changes.)
My form is showing up in design, but not form view. There are 700+ records.
In Design View -> Data, the Record Source is:
SELECT act.* FROM act;
This query shows all records in Query view.
There are no filters, and Allow Form View is set to Yes.
What is causing my form not to show?
EDIT: I'm noticing that the form is extremely wide. There isn't a width setting, but in Design view with window maximized I have to scroll way over to see the right edge. Would this have anything to do with it?
This link might help you. I remember having this issue and it was because of a read-only query.
Why does my form go completely blank?
Here is an excerpt that lists the main conditions why this could happen:
Condition (a) can be triggered in several ways. Examples:
- The form's Data Entry property is set to Yes. (This means the form shows no existing records, i.e. it is for entering new ones only.)
- The form has a Filter applied (or is opened with a WhereCondition) that yields no records.
- The form is based on a query where the criteria yield no records.
- The form is based on a table that has no records.
Condition (b) can be also be triggered by several things:
- The form's Allow Additions property is set to No.
- The form's Recordset Type property is set to something other than Dynaset.
- The form is based on a read-only query. (If you cannot add a record directly to your query, see Why is my query read-only?)
Auto_title_0 was set to 21" wide. Resizing that to the actual form width solved the problem.
On Design View of the Form click on "Details" which is just below the ruler and make sure that Visible is set to Yes on the Property Sheet.
Try this step.
Click to select Form.
Click on Auto Resize.
Change value to Yes.
Look into this
I also had the issue with a Form I used to input the strings for a query. The problem was that there were no records to answer query as I had changed it to an "Select Distinct" query to get rid of duplicate answers, but it also eliminated new record sets. Deleting the "Distinct" in my SQL solved the problem. Thanks for your help!
For me - the Form.Data Entry property was set to Yes.
Changing it to No shows the form again.
As for my case, I had open two forms.
Form B is link to Form A.
When Form B is opened, Form A is blank because it does not allow for data to be added.
When I close Form B and re-open (or refresh) Form A, the form fields appear.
Hope someone finds this helpful.. I faced this problem and solved by changing Pop On property (under the other tab) to No, and also changing the border style to "Dialog" in design view mode.
I also had this problem which wasted lots of time, but I was able to fix it.
The reason for me was that my target table was empty and I had primary keys set on it and had my controls in my form related to those fields.
So, Access was unable to show blank primary keys and was not displaying the form at all.
If you fill up your target table with some data, save and close the form and open it again the controls will be displayed.
On a form, I have a combobox, with the RowSource coming from a query (specifically, a calculated field in the query). When the user makes a selection, I want to update a label on the same form with a different column from that same query, but of course associated to the selection.
I'm fine with VBA and writing queries and whatnot, but I am not very familiar with Access forms.
By the way, I tried searching for an answer to this, but it was quite difficult because I don't know what this thing is really called that I am trying to do. A good link to a site explaining this would be perfectly fine (no need to write a bunch of stuff here if it already exists elsewhere).
In the After Update event of my combo box, cboUserID, I can set a label control, lblFoo, to the value of the second column in the selected row of the combo.
Me.lblFoo.Caption = Me.cboUserID.Column(1)
If your combo box is bound to a field in the form's record source, you may want to do that same operation from the form's On Current event also.
You can use the column property to refer to anything other than the bound column of a combo.
Rowsource: SELECT ID, SName, FName FROM Table
Me.MyCombo.Column(2)
This would return FName.
-- http://msdn.microsoft.com/en-us/library/aa224084(v=office.11).aspx
Me.MyLabel.Caption = Me.MyCombo.Column(2)