Field focus and making MDE files (1 Viewer)

jrjr

A work in progress
Local time
Today, 10:27
Joined
Jul 23, 2004
Messages
291
When I insert this code:

Private Sub Phone_Click()
Me.Phone.SelStart = 0
End Sub

Access will no longer make an MDE file. I was trying to make it so when the Phone field was clicked in the focus would be at the beginning of the field.

If I remove these lines, an MDE is possible again. I have tried it at the beginning and at the end. Any thoughts?
 

ghudson

Registered User.
Local time
Today, 10:27
Joined
Jun 8, 2002
Messages
6,195
Your code does not compile (code errors) if you are not able to convert to MDE. This will do what you want...

Code:
    Me.Phone.SetFocus
    Me!Phone.SelStart = Me!Phone.SelStart
 

jrjr

A work in progress
Local time
Today, 10:27
Joined
Jul 23, 2004
Messages
291
Private Sub Phone_Click()
Me.Phone.SetFocus
Me!Phone.SelStart = Me!Phone.SelStart
End Sub

This will not compile either, and does not set focus at the beginning of the field.
Also tried:

Private Sub Phone_Click()
Me.Phone.SetFocus
Me!Phone.SelStart = 0
End Sub

That sets focus at beginning but wont compile
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:27
Joined
Aug 30, 2003
Messages
36,125
Curious, as I tried this and it works/compiles/allows MDE creation (A2k):
Code:
Private Sub operator_Click()
  Me.operator.SelStart = 0
End Sub
 

jrjr

A work in progress
Local time
Today, 10:27
Joined
Jul 23, 2004
Messages
291
I am using 2000 as well...
It works nicely to bring focus to the beginning of the field.
It won't compile for me though, this is the first trouble I have had ever compiling anything.
 

jrjr

A work in progress
Local time
Today, 10:27
Joined
Jul 23, 2004
Messages
291
Ok, I figured it out with debug. For some reason this code brought another error into focus that was being missed before. That is strange because if I deleted these few lines it would compile fine. Well, I am set now but will have to work on what I removed and get it right. Thanks for the help guys!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:27
Joined
Aug 30, 2003
Messages
36,125
Can you post a small sample db, since it only seems to be a problem in your specific situation? There must be something else going on.

Edit: never mind, we posted at the same time. Glad you sorted it out.
 

ericlee

New member
Local time
Today, 22:27
Joined
Apr 6, 2005
Messages
5
ghudson said:
Your code does not compile (code errors) if you are not able to convert to MDE. This will do what you want...

Code:
    Me.Phone.SetFocus
    Me!Phone.SelStart = Me!Phone.SelStart

I have trouble to make a MDE file. I know that I have a lot of code that are not used in the code. How can I compile the program and get rid of them.

Thanks.
 

Users who are viewing this thread

Top Bottom