how to solve this error?

ariansman

Registered User.
Local time
Today, 13:49
Joined
Apr 3, 2012
Messages
157
I made a form over a query and added a button to go and view next records. Then I added two unbound text boxes named: delay1 and delay2. Then I put this code in the visual basic:
Sub delay1_AfterUpdate()
Me.dealay2 = 4
End Sub

The above code works only for the first record of the query but when I push the “next” button, I see the following error:
“The expression after update you entered was the event property setting produced error: A problem occurred while Microsoft access was communicating with the OLE server or ActiveX control.
This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to = [Field], this error occurs because a macro or event name is expected to run when the event occurs.”
I would appreciate any guide and comment.
Thank you
 
How does delay1 get updated? There is something else going on here. My suggestion would be to go the the properties of the form and locate the event "OnCurrent" This kicks off when you move to another record. Put your code updating delay2 in there. Then watch delay1 and see, not just how it is getting updated, but how often. I think your error is caused by the code trying to update a field before the move to a new record is finished. Additionally, fields have many characteristics, so change your code to say me.delay2.value = 4. The .value tells access you want the change the value, not the special effect or color or any other characteristic of the box.

If you are trying to find out how long it takes to move between records, put some code in the next record button and get the time when it is clicked, store that in a variable, and when you get to the next record, using OnCurrent, get the new time and subtract the two. Then just display the time to move, meaning you only need one box.
 
form properties/event/oncurrent is blank.
Textbox.delay1 properties/event/afterupdate: [event procedure]. When i press the button on the right, it goes to visual basic window where I can see the code that I had put.
I expect the textbox.delay2 to show “4” automatically when I write in textbox.delay1 and then click in another place in the form. This normally happens in other forms that I have ever made but not here. I am thinking maybe this happens because this form is made on a query not a table.
 
I must be missing something.

Code:
Sub delay1_AfterUpdate()
Me.dealay2 = 4
End Sub

If you want delay2 to display the number 4 no matter what is entered in delay1, then why the code to begin with? Why not just make the default value 4, or better yet use a label?

The above code works only for the first record of the query but when I push the “next” button, I see the following error:

Check to make sure you didn't end up with something bogus in the After Update event of the form.

Additionally, fields have many characteristics, so change your code to say me.delay2.value = 4. The .value tells access you want the change the value, not the special effect or color or any other characteristic of the box.

.Value is the default property in VBA, so there is no need to explicitly reference it.
 
Thank you,
I am confused as I have always used this code in similar situations and it has been working.
I used those unbound textboxes and referring merely to a number to simplify the problem and see that it still is not working. In other words “afterupdat” or “change” does not work. It seems these codes only works if a form is built over a table and if it is built over a query it does not work. Is that true?
Plus I also saw a second problem as following:
Here is a simplified of what I am doing and also the other problem. I made a form, named formA over a query with about 3 blanks: txt1, txt2 and txt3. While formA is open, pushing a bottom a new form is opened named formB, which one of its blanks should be filed automatically exactly with the same data as in formA when a blank named txt1 is updated/changes. I have put this code in formB:
Private Sub txt1_AfterUpdate()
Me!txt2 = Forms![formA]![txt2]
End Sub
By updating txt1 in formB access prompts me to debug, saying: Microsoft office cannot find the referenced form “FormA”. I am coming to the idea that both problems are made because formA is made on a query, because this code works if FormA was a form made over a table.
Thank you
 
It seems these codes only works if a form is built over a table and if it is built over a query it does not work. Is that true?

No. It makes no difference if the form is based on a table or a query.

By updating txt1 in formB access prompts me to debug, saying: Microsoft office cannot find the referenced form “FormA”.

If you're using a method like that then FormA needs to remain open so the value can be retrieved.

If you can upload a sanitized sample db that duplicates the problem I can look into it further.
 
thank you very much for your time,
i rebuilt it again and now it is working, i could not find what caused that problem though.
 

Users who are viewing this thread

Back
Top Bottom