Conditional formatting based on the values in another table (1 Viewer)

MajP

You've got your good things, and you've got mine.
Local time
Today, 07:26
Joined
May 21, 2018
Messages
8,527
I did not get an error which means it is likely a timing issue. When you load a subform, it loads before the main form. So this event could occur before the parent form is loaded, and give you an error. Probably something like object does not exist.

You might get lucky by adding Do events. In other words before that code fires it will give resources back to the other events to occur. Or just ignore the error. In that case the subform event will occur and the error will be ignored, but the event will fire again and work once the main loads.

Private Sub Form_Current()
DoEvents
On Error Resume Next
Me.Parent.txtLinkCons = Me.cons
End Sub
 
  • Like
Reactions: lbs

lbs

Registered User.
Local time
Today, 12:26
Joined
Dec 22, 2019
Messages
109
I did not get an error which means it is likely a timing issue. When you load a subform, it loads before the main form. So this event could occur before the parent form is loaded, and give you an error. Probably something like object does not exist.

You might get lucky by adding Do events. In other words before that code fires it will give resources back to the other events to occur. Or just ignore the error. In that case the subform event will occur and the error will be ignored, but the event will fire again and work once the main loads.

Private Sub Form_Current()
DoEvents
On Error Resume Next
Me.Parent.txtLinkCons = Me.cons
End Sub
Yes, DoEvents helped. No more error messages. Thanks a lot.
 

Users who are viewing this thread

Top Bottom