Go To Top of Form

E

Erwin Bormans

Hi all

I've got the following problem.

When I load a form it has to check some details on that form and to do those
checks I use .setfocus. The result is that when he displays the form it
shows it somewhere in the middle (the form is larger than my screen), do I
need to scroll to the top myself to see the first fillin field.

Is there someway to say show the top of the form or move the vertical
scrollbar to the top?

Kind regards
Erwin
 
A

Albert D. Kallal

Erwin Bormans said:
Hi all

I've got the following problem.

When I load a form it has to check some details on that form and to do
those checks I use .setfocus.

Why not just make sure your last set focus command places the cursor or
focus where were you want?

Furthermore I don't think you need to use the set focus to pull and test
values of contorls on a form. You simply should NEVER use the .text property
of a control.

You can/should use

me.MycontolName.Value

If for some strange reason got in the habit of using the .text property of a
control, this would explain your fascination with using set focus. Remember,
the .text property is only valid when a control has the focus, and should
NOT be used for general coding practices to set or grab the value of a
control. In fact, after writing heavy duty MS applications for 10 years, I
can only recall using the .text property maybe once in that long long period
of time.

Unless there is some other strange reason that you're using set focus on
your form, I would suggest that you simply use the .value property of a
controll to test, get, or set its value.

I should point out that if you come from a vB6 programming environment, the
..text property is what they used as standard fare in most of their
applications. The .text has a VERY different meaning and use when you're
working with MS access.

Simply use:

me.Mycontorl.Value

in most cases you can simply use:

me.Mycontrol

as the .value is the default property for a control.

If you remove all of your set focus code to examine those controls on the
form, then the form will not jump around nor will it be scrolled in a
fashion that needs correction after you you've run your code.
 
E

Erwin Bormans

Hi

I put the last focus on the object that I want , but then he leaves the
title of the form out of vision. Thats why I was looking for some code to
show the top of the form.

Than all the explaination about .text and .value I find very intresting, but
I have the following problem with .value:

I want to check if some details are filled in or not. I tried following
code:

If Me.Tekst2.Value = Null Or Me.Tekst2.Value = "" Then
MsgBox "Tekstvak leeg"
Else
MsgBox "Tekstvak NIET leeg"
End If

But it doesn't matter if the textbox is empty or not he always shows the
messagebox "not empty".

Is there another way to check if a textbox is empty and use the .value?

Thx a lot
Kind regards
Erwin
 
D

Douglas J. Steele

You cannot use = Null: Null is a special value, and you can't use normal
comparisons for it.

Use either

If IsNull(Me.Tekst2.Value) Or Me.Tekst2.Value = "" Then
MsgBox "Tekstvak leeg"
Else
MsgBox "Tekstvak NIET leeg"
End If

or, slightly more efficient (not that you'll notice a difference)

If Len(Me.Tekst2.Value & vbNullString) = 0 Then
MsgBox "Tekstvak leeg"
Else
MsgBox "Tekstvak NIET leeg"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top