Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Sat, 04 Oct 2008 20:10:23 +0200,    group: microsoft.public.access.formscoding        back       


Can not get focus   
I wrote this code:

If [Forms]![verslagen].[Vragen]!Selectievakje15 = False Then
  Me!teller = Me!teller - 1
  If MsgBox("Opmerking?", vbOKOnly, "Let op!!") = vbOK Then
   [Forms]![verslagen]![Vragen].Form!Selectievakje15 = True
   [Forms]![verslagen]![Vragen].Form!Remarks_tekst.Visible = True
   [Forms]![verslagen]![Vragen].Form!Bewaren.Enabled = True
   [Forms]![verslagen]![Vragen].Form!Remarks.Visible = True
   [Forms]![verslagen]![Vragen].Form!Remarks_tekst.Caption = "Opmerk:"
   [Forms]![verslagen]![Vragen].Form!Remarks = ""
   [Forms]![verslagen]![Vragen].Form!Remarks.SetFocus
  End If
Else
  [Forms]![verslagen].[Sub_Bedrijsgegevens].Visible = False
  [Forms]![verslagen].[Vragen].Visible = False
  [Forms]![verslagen].[Opdrachten].Visible = True
End If

I expect Remarks to get focus and the cursor is put into this entryfield.
But, not so
I get focus on the pushbutton that launches this code.

What am I doning wrong?
date: Sat, 04 Oct 2008 20:10:23 +0200   author:   Jean-Paul

Re: Can not get focus   
Vragen is a subform, correct? You need two SetFocus steps to set focus to a 
control within a subform -- the first sets focus to the subform control, the 
second sets focus to the control in that subform:

   [Forms]![verslagen]![Vragen].SetFocus
   [Forms]![verslagen]![Vragen].Form!Remarks.SetFocus

-- 

        Ken Snell
<MS ACCESS MVP>


"Jean-Paul"  wrote in message 
news:hkOFk.2632$DZ4.807@newsfe09.ams2...
>I wrote this code:
>
> If [Forms]![verslagen].[Vragen]!Selectievakje15 = False Then
>  Me!teller = Me!teller - 1
>  If MsgBox("Opmerking?", vbOKOnly, "Let op!!") = vbOK Then
>   [Forms]![verslagen]![Vragen].Form!Selectievakje15 = True
>   [Forms]![verslagen]![Vragen].Form!Remarks_tekst.Visible = True
>   [Forms]![verslagen]![Vragen].Form!Bewaren.Enabled = True
>   [Forms]![verslagen]![Vragen].Form!Remarks.Visible = True
>   [Forms]![verslagen]![Vragen].Form!Remarks_tekst.Caption = "Opmerk:"
>   [Forms]![verslagen]![Vragen].Form!Remarks = ""
>   [Forms]![verslagen]![Vragen].Form!Remarks.SetFocus
>  End If
> Else
>  [Forms]![verslagen].[Sub_Bedrijsgegevens].Visible = False
>  [Forms]![verslagen].[Vragen].Visible = False
>  [Forms]![verslagen].[Opdrachten].Visible = True
> End If
>
> I expect Remarks to get focus and the cursor is put into this entryfield.
> But, not so
> I get focus on the pushbutton that launches this code.
>
> What am I doning wrong?
date: Sat, 4 Oct 2008 14:21:15 -0400   author:   Ken Snell \(MVP\) etl

Re: Can not get focus   
On Sat, 04 Oct 2008 20:10:23 +0200, Jean-Paul 
wrote:

Your first IF statement is probably wrong and should be:
If [Forms]![verslagen]![Vragen].Form!Selectievakje15 = False

You can probably replace all occurrences of "[Forms]![verslagen]" with
"Me". You can also use a With block to make your code more readable:
With Me!Vragen.Form
  !Selectievakje15 = True
End With

Curious that you're testing a MsgBox with vbOKOnly for vbOK. You could
just write:
MsgBox "Opmerking?", vbOKOnly or vbExclamation, "Let op!!"
or since vbOKOnly is default:
MsgBox "Opmerking?", vbExclamation, "Let op!!"
(but I like to be explicit)

Setting focus to a control in a subform is a two-step process:
[Forms]![verslagen]![Vragen].SetFocus
[Forms]![verslagen]![Vragen].Form!Remarks.SetFocus
Or at least it used to be. I just tested this in A2007 (Northwind
Order Details form) and the first line can be omitted.

-Tom.
Microsoft Access MVP


>I wrote this code:
>
>If [Forms]![verslagen].[Vragen]!Selectievakje15 = False Then
>  Me!teller = Me!teller - 1
>  If MsgBox("Opmerking?", vbOKOnly, "Let op!!") = vbOK Then
>   [Forms]![verslagen]![Vragen].Form!Selectievakje15 = True
>   [Forms]![verslagen]![Vragen].Form!Remarks_tekst.Visible = True
>   [Forms]![verslagen]![Vragen].Form!Bewaren.Enabled = True
>   [Forms]![verslagen]![Vragen].Form!Remarks.Visible = True
>   [Forms]![verslagen]![Vragen].Form!Remarks_tekst.Caption = "Opmerk:"
>   [Forms]![verslagen]![Vragen].Form!Remarks = ""
>   [Forms]![verslagen]![Vragen].Form!Remarks.SetFocus
>  End If
>Else
>  [Forms]![verslagen].[Sub_Bedrijsgegevens].Visible = False
>  [Forms]![verslagen].[Vragen].Visible = False
>  [Forms]![verslagen].[Opdrachten].Visible = True
>End If
>
>I expect Remarks to get focus and the cursor is put into this entryfield.
>But, not so
>I get focus on the pushbutton that launches this code.
>
>What am I doning wrong?
date: Sat, 04 Oct 2008 11:40:26 -0700   author:   Tom van Stiphout

Re: Can not get focus   
Great... problem solved!!!
Thank you both
JP

Ken Snell (MVP) wrote:
> Vragen is a subform, correct? You need two SetFocus steps to set focus to a 
> control within a subform -- the first sets focus to the subform control, the 
> second sets focus to the control in that subform:
> 
>    [Forms]![verslagen]![Vragen].SetFocus
>    [Forms]![verslagen]![Vragen].Form!Remarks.SetFocus
>
date: Sat, 04 Oct 2008 21:48:53 +0200   author:   Jean-Paul

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us