Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

focus after click

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Matt - 15 May 2008 21:09 GMT
All,
I have a form that has a button to advance to the next record labeled
"Next".  I am able to advance to teh next record but the focus is still in
the button and not the 1st textbox "Call".  

I tried using "me.call.setfocus" in several places both on the command
button and "call" textbox.  since it is not working I am not putrting it in
the right place.  I'm 90% sure I am using the setfocus right.  I could be
wrong though.

This is being used for an event registration.  I need to make it "idiot
proof".

Thanks.
Signature

73,
Matt

Klatuu - 15 May 2008 21:42 GMT
In the code for the Next button's Click event.  Add as the last line:

   Me.[Call].SetFocus

Note the brackets.  Call is a reserved VBA word, so that may be causing an
issue.  I would recommend renaming the control.
Signature

Dave Hargis, Microsoft Access MVP

> All,
> I have a form that has a button to advance to the next record labeled
[quoted text clipped - 10 lines]
>
> Thanks.
Matt - 15 May 2008 21:52 GMT
Thanks Dave for the reply.  It didn't work so I am posting it here.

Private Sub Next_Click()
On Error GoTo Err_Next_Click

   DoCmd.GoToRecord , , acNext

Exit_Next_Click:
   Exit Sub

Err_Next_Click:
   MsgBox Err.Description
   Resume Exit_Next_Click
   
    Me.[call].SetFocus
End Sub
Signature

73,
Matt

> In the code for the Next button's Click event.  Add as the last line:
>
>     Me.[Call].SetFocus
>
> Note the brackets.  Call is a reserved VBA word, so that may be causing an
> issue.  I would recommend renaming the control.
Matt - 15 May 2008 21:55 GMT
Sorry I did change the name and I posted what I had before the change.  
Here's the updated string.  It still doesn't work.  I am not betting an error
msg but I must have it in the wrong place.  Thanks again.

Me.[call].SetFocus

Signature

73,
Matt

Klatuu - 15 May 2008 22:03 GMT
Well, it didn't work because you did exactly what I told you to do.
Sorry, I didn't know you had good error handling in your code.  It should be
like this:

Private Sub Next_Click()
On Error GoTo Err_Next_Click

   DoCmd.GoToRecord , , acNext
   Me.[call].SetFocus

Exit_Next_Click:
   Exit Sub

Err_Next_Click:
   MsgBox Err.Description
   Resume Exit_Next_Click
   
End Sub

Signature

Dave Hargis, Microsoft Access MVP

> Thanks Dave for the reply.  It didn't work so I am posting it here.
>
[quoted text clipped - 19 lines]
> > Note the brackets.  Call is a reserved VBA word, so that may be causing an
> > issue.  I would recommend renaming the control.
Matt - 15 May 2008 22:13 GMT
OK I did that and I get error "Object doesn't support this object or method"

Signature

73,
Matt

> Well, it didn't work because you did exactly what I told you to do.
> Sorry, I didn't know you had good error handling in your code.  It should be
[quoted text clipped - 14 lines]
>    
> End Sub
Klatuu - 15 May 2008 22:17 GMT
As I said before, Call is a reserved word.  It may be that even in brakets it
is having a problem.  Try changing the name of the text box to txtCall and
change any code that references the name.
Signature

Dave Hargis, Microsoft Access MVP

> OK I did that and I get error "Object doesn't support this object or method"
>
[quoted text clipped - 16 lines]
> >    
> > End Sub
Matt - 15 May 2008 22:33 GMT
I did change it to "callsign"  I now changed it to "txtcall" like you
suggested.  I still get the same error. Here is my entire code:

Private Sub txtcall_AfterUpdate()
   Me![txtcall] = UCase(Me![txtcall])
End Sub

Private Sub email_AfterUpdate()
   Me![email] = LCase(Me![email])
End Sub

Private Sub name_AfterUpdate()
   Me![name] = StrConv(Me![name], 3)
End Sub

Private Sub Next_Click()
On Error GoTo Err_Next_Click

DoCmd.GoToRecord , , acNext
Me.[txtcall].SetFocus

Exit_Next_Click:
Exit Sub

Err_Next_Click:
MsgBox Err.Description
Resume Exit_Next_Click

End Sub

Private Sub clear_Click()
On Error GoTo Err_clear_Click

   DoCmd.RunCommand acCmdUndo

Exit_clear_Click:
   Exit Sub

Err_clear_Click:
   MsgBox Err.Description
   Resume Exit_clear_Click
   
End Sub

Private Sub Unit_Camp_name_AfterUpdate()
   Me![Unit/Camp name] = StrConv(Me![Unit/Camp name], 3)
End Sub

The help for this error says I need to put the setfocus before the compile.  
I hae tried different locations and have not found the answer.

This is frustrating!  Thanks for the help Dave.  I really appreciate it.
Signature

73,
Matt

> As I said before, Call is a reserved word.  It may be that even in brakets it
> is having a problem.  Try changing the name of the text box to txtCall and
> change any code that references the name.
Klatuu - 15 May 2008 22:40 GMT
Oh, I didn't know you had already changed the name.

Try using the bang instead of the dot
Me![txtcall].SetFocus

It shouldn't make a difference and I don't know why it isn't working.  Is
txtCall enabled and not locked?  Are you able to put the cursor in the
control and make changes to it?

Honestly, Matt, this is a bit strange.
Signature

Dave Hargis, Microsoft Access MVP

> I did change it to "callsign"  I now changed it to "txtcall" like you
> suggested.  I still get the same error. Here is my entire code:
[quoted text clipped - 52 lines]
> > is having a problem.  Try changing the name of the text box to txtCall and
> > change any code that references the name.
Matt - 15 May 2008 23:33 GMT
Thanks for your help Dave.  I have just taken that button all the way out.  I
ended up with another issue now.  My UCase for the same txtcall field is now
not working.  I am going to try and fix that and forget the button.

I'm on a time schedule also.  I have to have it for a convention tomorrow.  
I'll just cut my losses.

And fix my Ucase.

Thanks again!
Signature

73,
Matt

> Oh, I didn't know you had already changed the name.
>
[quoted text clipped - 6 lines]
>
> Honestly, Matt, this is a bit strange.
Clif McIrvin - 16 May 2008 00:56 GMT
Hi. I've not followed this whole thread, and I see that you note you're
under a serious timeframe, so this may be of no help at all, but here
goes:

As a 'newbie', I've run into problems with .setfocus when changing
records triggered *other* events. It's entirely possible (perhaps even
likely?) that I simply missed documentation that would have headed me
off at the pass, so to speak.  In the end, I tracked the issue down by
sprinkling debug.print "name of routine "; [relevant variable data if
any];now() liberally throughout my code and discovered that various
routines were interrupted.

(Also, I didn't examine your code to see if I noticed any likely traps;
just sharing a bit of personal experience in case it might be of use to
someone else.)

Signature

Clif
Still learning Access 2003

> Thanks for your help Dave.  I have just taken that button all the way
> out.  I
[quoted text clipped - 22 lines]
>>
>> Honestly, Matt, this is a bit strange.

Signature

Clif
Still learning Access 2003

Linq Adams - 16 May 2008 01:47 GMT
You also need to change the name of your "Name" field! "Name" is a reserved
word in Access, and is, in fact, an Object Property.

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Jason - 18 May 2008 04:08 GMT
I've use NAME ok although I would like to get rid of it and other field
names - The data files I import from have that field. I just use me.name
when I refer to the form name and me!name for the field when VBA doesn't
process properly.
> You also need to change the name of your "Name" field! "Name" is a reserved
> word in Access, and is, in fact, an Object Property.
Steve - 16 May 2008 04:01 GMT
Hi
I am also new to all of this access stuff but I have learnt a few simple
rules and one is to try and use the naming convention for buttons and boxes
etc
A command button name would always start with cmd (cmdCall) this will always
give you a unique name and also when tying to debug you know what the item is
but its naming convention. All names starting with Cmd are command buttons.
Secondly when you select an new record with your next command that record
now becomes the current recode so I would put the me.cmdCall.setfocus in the
On current event for the form. So every time you select a record the command
button cndCall should become the active item on the form.
Hop some of this is of some help
Steve

> All,
> I have a form that has a button to advance to the next record labeled
[quoted text clipped - 10 lines]
>
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.