vba GoToRecord acGoTo not working
-
21-12-2019 - |
Question
So the problem that I believe has come up for other people but the solutions that I found are not working yet.
Private Sub DROPDOWN_Change()
Me!FORMAL_CERT_PROCEDURE_TEST_SCRIPTS_THING.SetFocus
DoCmd.GoToRecord acDataForm, "FORMAL_CERT_PROCEDURE_TEST_SCRIPTS_THING", acGoTo, Me.DROPDOWN.Value
End Sub
I am getting the error "The object 'FORMAL_CERT_PROCEDURE_TEST_SCRIPTS_THING' isn't open."
Solution
When you leave the ObjectType and ObjectName options for DoCmd.GoToRecord
blank, Access uses the active object. Since your code has just done SetFocus
on the FORMAL_CERT_PROCEDURE_TEST_SCRIPTS_THING
subform control, change the DoCmd.GoToRecord
statement ...
Private Sub DROPDOWN_Change()
Me!FORMAL_CERT_PROCEDURE_TEST_SCRIPTS_THING.SetFocus
DoCmd.GoToRecord , , acGoTo, Me.DROPDOWN.Value
End Sub
As an alternative to this approach, consider whether you can accomplish what you need with the subform control's link master/child fields property. Perhaps Me.DROPDOWN
can match a field in the subform's record source?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow