cannot find control - runtime 2424

rikklaney1

Registered User.
Local time
Today, 10:18
Joined
Nov 20, 2014
Messages
157
Ok, I'm stumped!

I have this in my timer event

If Me.chkdone = True Then
Me.Command170.Visible = False
Me.Command171.Visible = True
Else
Me.Command170.Visible = True
Me.Command171.Visible = False
End If

and it hangs on the first line saying it can't find the control. I can rem out these lines and switch the checkbox from the table and watch it change on the form but when this is active it says it can't find the control. Iv'e tried putting this in the afterupdate for me.chkdone and I get nothing. Any ideas what I've got wrong? It runs a compile without any errors and I'm just stumped.
 
chkdone needs to be the name of the control - is it spelt correctly?


It runs a compile without any errors and I'm just stumped
do you have Option Explicit just below Option Compare Database at the top of the vba module? If not, put it in and compile again
 
yep. It's spelt correctly. I'm wondering if the problem might be in the table instead since I just tried this

If DLookup("[done]", "[constants_stations]", "[id] = '" & Me.ID & "'") = False Then Me.Command171.Visible = True Else Command171.Visible = False
If DLookup("[done]", "[constants_stations]", "[id] = '" & Me.ID & "'") = True Then Me.Command170.Visible = True Else Command170.Visible = False


and got the same result. Actually this time it was a 3464 error.
 
ok. I got it to work! Used this...

If DLookup("[done]", "[constants_stations]", "[id] = forms!frm_operator.id") = False Then Me.Command171.Visible = True Else Command171.Visible = False
If DLookup("[done]", "[constants_stations]", "[id] = forms!frm_operator.id") = True Then Me.Command170.Visible = True Else Command170.Visible = False
I really wanted to avoid dlookup but... it works now. Thanks for the help.
 
chkdone needs to be the name of the control - is it spelt correctly?

Ditto for Command170 and Command171! Also, most odd that you're doing this n the Timer Event instead of using Form_Current as well as the AfterUpdate event of the Checkbox.

Linq ;0)>
 
I have it on the timer event because the op will hit a button on tbeir form and that tells a main timer that the ops are ready. When all the ops are ready it resets them all for the next unit. So it needs to keeps checking when a new unit has started so the op has a status of either "complete" or "working" depending on which commamd button is visible. I tried it with toggle buttons but kept running into "record has been edited by another user" errors. Is there a better way to monitor when the check in the table changes?
 
I believe I originally had it in the after update event for chkdone but it didn't work. Of course I need to retry it with the new, working, code.
 
And you should rename your command buttons to something meaningful, having command170 and 171 only complicate things
 
I have it on the timer event because the op will hit a button on tbeir form and that tells a main timer that the ops are ready. When all the ops are ready it resets them all for the next unit. So it needs to keeps checking when a new unit has started so the op has a status of either "complete" or "working" depending on which commamd button is visible. I tried it with toggle buttons but kept running into "record has been edited by another user" errors. Is there a better way to monitor when the check in the table changes?

I believe if you save the record you can avoid the errors. I believe a
Code:
Me.Recalc

will do it, If not then.
Code:
DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom