Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: Very hard question

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default


    I need some code for my userform to perform an action. I dont think it's possible, but it's worth asking.

    When I click a command button, I need it to unload the userform, then make it open again 2 minutes later. Then it remains open until the button is pressed again.

    I tried using OnTime but it kept looping and I just need it to happen once, when the button is pressed

    Does anyone know how I can do this?

    Janie



  2. #2
    MrExcel MVP
    Colo's Avatar
    Join Date
    Mar 2002
    Location
    Kobe, Japan
    Posts
    1,456
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    2 Thread(s)

    Default

    Hi. Why dont't you use flag?


    'Standerd module
    Dim flg As Boolean
    Sub Test()
    UserForm1.Show
    End Sub

    Sub ReLoad()
    If Not flg Then UserForm1.Show
    flg = True
    End Sub

    'Userform1 Module

    Private Sub CommandButton1_Click()
    Unload Me
    Application.OnTime Now + TimeValue("00:02:00"), "ReLoad"
    End Sub

    Hope this helps + pen pineapple apple pen!

    Masaru Kaji aka Colo - cellmasters.net

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default


    That's crazy, I was just testing something similar!!

    Mine's a little cruder than yours. Mine is:

    'userform module
    Unload Me
    Application.OnTime Now+TimeValue("00:02:00"),"Againplease"

    'Standard Module
    sub Againplease()
    Userform1.show
    End sub

    Mine works fine. What are the benefits of having flags? If they're beneficial I'll use your's

    Thnaks for your help

    Janie xx

  4. #4
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try the following;

    Note: That The ontime method should be dismissed properly other wise it will run
    again.....

    In A Std Module


    Option Explicit
    Public tTime

    Sub UFrm_Show()
    Load UserForm1
    UserForm1.Show
    End Sub

    Sub ShowAfter()
    Application.OnTime tTime, "UFrm_Show"
    End Sub




    In the UF Module;


    Private Sub CommandButton1_Click()

    tTime = Now() + TimeSerial(0, 2, 0)
    Application.OnTime tTime, procedure:="UFrm_Show"
    Unload Me

    End Sub

    Private Sub UserForm_Initialize()
    On Error Resume Next
    Application.OnTime tTime, procedure:="ShowAfter", schedule:=False
    On Error GoTo 0
    End Sub




    _________________
    Kind Regards,
    Ivan F Moala
    Have a Nice day

    [ This Message was edited by: Ivan F Moala on 2002-05-09 03:02 ]

  5. #5
    Board Regular
    Join Date
    Apr 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default


    Thanks for all your help, so much for it being a very hard question!

  6. #6
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-05-09 03:00, buntykins wrote:

    Thanks for all your help, so much for it being a very hard question!
    Pfft, I didn't even bother replying, it was so trivial .

  7. #7
    Board Regular
    Join Date
    Apr 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default


    He he, sure Mudface, sure...

    Maybe you should change your name to Egg-On-Face

    xx


  8. #8
    New Member
    Join Date
    May 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-05-09 03:16, buntykins wrote:

    He he, sure Mudface, sure...

    Maybe you should change your name to Egg-On-Face

    xx

    Don't you dare .

  9. #9
    Board Regular
    Join Date
    Apr 2002
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default


    LOL!!

    I concede

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •