macro or function preventing saving date to a field. (1 Viewer)

John Sh

Member
Joined
Feb 8, 2021
Messages
474
That title should read DATA, not DATE.


I am getting this message after update on a combobox.
Screenshot_39.jpg

There are no macros or functions in either the "afterupdate" or "gotfocus" events of the two controls involved.
I have run the debugger a number of times and even changed the destination control from a textbox to a combobox with the same result.
Putting a break point at the afterupdate event stops the program until F8 is pressed and the message pops up immediately without the software apparently progressing to the "setfocus" command.
I have just updated to v2016 but this behaviur was not noticed immediately after the change.
What have I done wrong???

txtcreatedby is, in fact, a combobox with a simple query as the rowsource and bound to a field. 'message to self, change the name.
when an item in the list is selected it immediately appears in the combobox then disappears until such time as the close button is clicked

The relevant field in the table is as the image below.
Screenshot_40.jpg


Code:
Private Sub txtCreatedBy_AfterUpdate()
    Me.cboTime.SetFocus
End Sub

Private Sub cboTime_GotFocus()
    Me.cboTime.BackColor = RGB(218, 255, 94)
    Me!cboTime.Dropdown
End Sub
CODE]

After clicking "OK" on the message and then clicking the form close button, the program resumes operation as if nothing has happened
 
Perhaps try setting Error Trapping to "Break on All Errors" in an attempt to find any code that is causing an error.
Alternatively, you could post a copy the db for us to examine.
 
That title should read DATA, not DATE.


I am getting this message after update on a combobox.
View attachment 112967
There are no macros or functions in either the "afterupdate" or "gotfocus" events of the two controls involved.
I have run the debugger a number of times and even changed the destination control from a textbox to a combobox with the same result.
Putting a break point at the afterupdate event stops the program until F8 is pressed and the message pops up immediately without the software apparently progressing to the "setfocus" command.
I have just updated to v2016 but this behaviur was not noticed immediately after the change.
What have I done wrong???

txtcreatedby is, in fact, a combobox with a simple query as the rowsource and bound to a field. 'message to self, change the name.
when an item in the list is selected it immediately appears in the combobox then disappears until such time as the close button is clicked

The relevant field in the table is as the image below.
View attachment 112968

Code:
Private Sub txtCreatedBy_AfterUpdate()
    Me.cboTime.SetFocus
End Sub

Private Sub cboTime_GotFocus()
    Me.cboTime.BackColor = RGB(218, 255, 94)
    Me!cboTime.Dropdown
End Sub
CODE]

After clicking "OK" on the message and then clicking the form close button, the program resumes operation as if nothing has happened
"There are no macros or functions in either the "afterupdate" or "gotfocus" events of the two controls involved."

The error message refers to the BeforeUpdate, not the AfterUpdate" event....
 
"There are no macros or functions in either the "afterupdate" or "gotfocus" events of the two controls involved."

The error message refers to the BeforeUpdate, not the AfterUpdate" event....
I missed that, there is no "beforeupdate" event in any of the controls involved.
 
The other possibility is some type of corruption. A DECOMPILE followed by a recompile might be in order as a relatively easy test.



NOTE that this is not a guaranteed fix. It MIGHT fix something - but more often than not, it will reveal if there is something else wrong. Which in this case I believe is a reasonable suspicion.
 
"There are no macros or functions in either the "afterupdate" or "gotfocus" events of the two controls involved."

The error message refers to the BeforeUpdate, not the AfterUpdate" event....
Try the approach @theDocMan suggested.

Also check the form's BeforeUpdate as well as those on the controls.
 
I have never had cause to use "beforeupdate" so that's ruled out.
It seems the problem is caused by a sub that has "on error resume next" at the top.
I use this sub to colour the form sections depending on the active form. Not all forms have the same controls and resume next was an easy out.
I will clean up the code and hopefully fix the problem.

As an aside, the "break on all errors" is breaking on some odd things,

Screenshot_41.jpg

it indicates the section number is incorrect. if I replace "acheader" with "1" I get the same error.

As always, I thank you for your input.
John
 
Well that wasn't it.
I have renamed txtcreatedby to cbocreatedby
The cbocreatedby combobox has a list of three names.
If I select the second or third items I get the error. If I select the first item there is no error and I can then select any item in the list with no adverse consequences to program flow.
The entries in the table appear to be ok and the rowsource query functions as expected in view mode.
I will try <cbocreatedby = cbocreatedby.itemdata(0)> and see if that works.
 
setting the combobox to itemdata(0) has fixed the problem.
Even with break on all set, there was no indication of an error when the message appeared.
Access strikes again!!
 

Users who are viewing this thread

Top Bottom