Share via

msgbox displaying before the form opens

Anonymous
2013-12-29T17:12:18+00:00

This code runs, and the msgbox displays prior to the form loading on the screen. Is there any way to get the form to display before the msgbox displays?

Private Sub Form_Load()

On Error GoTo Blank

    txt_Test.Value = txt_ImpactedRoutes.Value

Blank:

    MsgBox "There were no Route Issues Reported for this day. Please select another date above."

End Sub

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Steve Rindsberg 99,166 Reputation points MVP Volunteer Moderator
2013-12-29T17:41:20+00:00

Part of the problem is your code's logic.

If it encounters an error, it'll display the message box.

If it doesn't encounter an error, it'll display the message box.

Try this instead:

Private Sub Form_Load()

On Error GoTo Blank

txt_Test.Value = txt_ImpactedRoutes.Value

NormalExit:

Exit Sub

Blank:

MsgBox "There were no Route Issues Reported for this day. Please select another date above."

Resume NormalExit

End Sub

You might also want to put the code in the Activate event instead of Load.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2013-12-30T19:16:38+00:00

    Thank you sir

    Was this answer helpful?

    0 comments No comments