Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Failure to Detect vbMinimized

Posted on 2007-11-18
6
Medium Priority
?
725 Views
Last Modified: 2012-06-21
I have a small program that's behaving very strangely. The problem code is something like this:

If Me.WindowState = vbMinimized Then
    lblResults.Caption = "long text"
Else
    Me.Caption = "short text"
End If

Pretty simple and as you might expect it works just fine on my PC and its Windows XP Professional SP2 OS. The problem is that when I install the app on my wife's PC which has Windows XP Multimedia Edition SP2 and run and minimize the app, the form's caption does not change to "short text" but rather remains at its default value.

I even went so far as to create my own IsMinimized property that depends on the form's Width and again while that works on my PC it doesn't on my wife's.

Does anyone have any idea what's going on?
0
Comment
Question by:Martin Liss
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 195 total points
ID: 20308598
"...and run and minimize the app, the form's caption does not change to "short text" but rather remains at its default value."

Here is your code:

    If Me.WindowState = vbMinimized Then
        lblResults.Caption = "long text"
    Else
        Me.Caption = "short text"
    End If

In plain English, it translates to:
(1) If the WindowState IS Minimized, then change the "lblResults" Caption.
(2) If the WindowState is NOT Minimized then change the Forms Caption.

If you want "short text" in the Forms Caption when the Form is Minimized then you need:

    If Me.WindowState = vbMinimized Then
        Me.Caption = "short text"
    Else
        lblResults.Caption = "long text"
    End If
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 20308601
* Also, when the form is restored, you currently don't have any code in place to change the caption BACK to whatever it was before "short text".
0
 
LVL 49

Author Comment

by:Martin Liss
ID: 20308626
After I posted the code I realized that what I wrote here was backward and should have been

If Me.WindowState = vbMinimized Then
    Me.Caption = "short text"
Else
    lblResults.Caption = "long text"
End If

And note that while this is just a mock up of the actual code, the actual code does work on my PC but not my wife's.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 180 total points
ID: 20320360
where do you put on your routine?


Private Sub Form_Resize()
 
If Me.WindowState = vbMinimized Then
    Me.Caption = "long text"
    lblResults.Caption = ""
Else
    Me.Caption = ""
    lblResults.Caption = "short text"
End If
 
End Sub

Open in new window

0
 
LVL 49

Author Comment

by:Martin Liss
ID: 20320393
I'm embarrased. I found the error and it had nothing to do with vbMinimized but rather an If statement that was blocking the changing of the caption.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 20320444
Lol...I'm pretty sure we've ALL done something similar at one point or another...  ;)

Glad you found the problem!  =)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question