Open a form and run a procedure after the form is opened (1 Viewer)

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
Hello,

I have this little problem where I am importing data and want to import the data when the forms open iand display the status bar in the screen. If try to run the procedure the procedure runs however the forms does show until the procedure finisheed. I need the form to be open show the status of transaction of importing the data. Basicaly pressing the Re-Import button when form is first opened. I Just can not figure this one out. Any ideas... I was thinking that perhaps an on timer event using a switch to tell then to stop the time at the end of the procedure and other ideas was to call the Click even of the button but I am sure if that is possible.
 

Attachments

  • Re Import Button.JPG
    Re Import Button.JPG
    79.1 KB · Views: 91
Last edited:

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:31
Joined
May 21, 2018
Messages
8,535
Order of events open>load>current
Try on load. At the beginning of the code add do Events
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 18:31
Joined
May 21, 2018
Messages
8,535
You can move to on current, but you will need a way to ensure it runs only once
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
MajP,

I tried on load on current but neither one show the form until the procedure is complete.
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
I do not like this method but does any body know to click on a button using VBA ?
 

GinaWhipp

AWF VIP
Local time
Today, 18:31
Joined
Jun 21, 2011
Messages
5,899
Hmm, perhaps you should post the code. We might be able to tweak it so it gets your desired results.
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
Hmm, perhaps you should post the code. We might be able to tweak it so it gets your desired results.
The code will not help because any body can try with using a simple message box. Just create a new form put out any object on the form. On the open (or load or current) place the message box such as Msg "Hello Word". you will see that the message will appear but the form until the message box is closedl. That is problem is to show the message box after the form is shown. I am wondering if this possible.
 

Attachments

  • I am getting this.JPG
    I am getting this.JPG
    17.1 KB · Views: 84
  • I need it like this.JPG
    I need it like this.JPG
    82.4 KB · Views: 86

GinaWhipp

AWF VIP
Local time
Today, 18:31
Joined
Jun 21, 2011
Messages
5,899
Okay, the built in message box is the problem. You need to make your own form and use it as a message box.
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
Okay, the built in message box is the problem. You need to make your own form and use it as a message box.
That still will not work because I need the form on the back ground. There is really no point in duplicating the form. I believe that I need to use the timer event to control when the event happens. For example a few seconds after the form is open call the procedure or perhaps have call it when an object get focus and use a switch to control that the procedure should be done when the from is opened not after. This are just some ideas that I may try.
 

GinaWhipp

AWF VIP
Local time
Today, 18:31
Joined
Jun 21, 2011
Messages
5,899
Well, not sure why you don't think that will work. I do it all the time because the built in message box opens in Dialog Mode which halts all code and actions until it is closed and when I make my own I can control that and much more. That said, good luck and feel free to back and let us know how it worked out.
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
GinnaWhipp it not that simple because I do not need a message I need to run a procedure. I had form that pop up with the timer, but I would and then forms opens. What I need though is do the process within on form not two forms. Thank you for the suggestion. I will keep thinking about it. I am sure that something may come up to solve this puzzle. .. I need something like the attached code in that I C#. I think I translate to VBA.
 

Attachments

  • Procedure Code.JPG
    Procedure Code.JPG
    26.7 KB · Views: 86
Last edited:

GinaWhipp

AWF VIP
Local time
Today, 18:31
Joined
Jun 21, 2011
Messages
5,899
That code work. If not you can post your database for us to have a look. You never know as there is always more than one way to skin a cat. (Apologies to the cat lovers!)
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
That code did the trick. I have posted the photos in case somebody wants to use this code.
 

Attachments

  • Define  Variable.JPG
    Define Variable.JPG
    80.1 KB · Views: 88
  • Set Variable to True on Open Form Event.JPG
    Set Variable to True on Open Form Event.JPG
    29.7 KB · Views: 93
  • Check  if variable is set to true.JPG
    Check if variable is set to true.JPG
    38.7 KB · Views: 89

missinglinq

AWF VIP
Local time
Today, 18:31
Joined
Jun 20, 2003
Messages
6,423
Try this (untested)
Code:
Private Sub Form_Open(Cancel As Integer)
  Me.TimerInterval = 1
End Sub

Private Sub Form_Timer()
  Me.TimerInterval = 0
  'Run proceedure here
End Sub
Linq ;0)>

Sorry...day late (well 4 minutes) and a dollar short!
 

Ryobi

Registered User.
Local time
Today, 17:31
Joined
Mar 5, 2012
Messages
49
Try this (untested)
Code:
Private Sub Form_Open(Cancel As Integer)
  Me.TimerInterval = 1
End Sub

Private Sub Form_Timer()
  Me.TimerInterval = 0
  'Run proceedure here
End Sub
Linq ;0)>

Sorry...day late (well 4 minutes) and a dollar short!

missinglinq,

That code might work.

Thanks
 

Users who are viewing this thread

Top Bottom