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.

In a sub-form : when entering a field, verify if another field is true, if so show a MsgBox + set focus on another field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Céline Brien - 13 May 2008 13:45 GMT
Hi everybody,
I receive an error message when I select HreHPLeger.
Can you help ?
Many thanks,
Céline

Private Sub HrsHPLeger_Enter()
If ([ccPrive] = -1) Then

  MsgBox "Membre privé", vbOKOnly, "Saisir les heures dans le champ
HrsLeger"
  Cancel = True
  Me.HrsLeger.SetFocus

End If
End Sub
Al Campagna - 13 May 2008 14:05 GMT
Celine,
   Whenever you receive an error message... please include that in your
post.

   At first glance, the Enter event doesn't have a Cancel, and you
shouldn't have to SetFocus when you have already entered the field.
   Try this...

Private Sub HrsHPLeger_Enter()
   If Me.[ccPrive] = -1 Then
       MsgBox "Membre privé", vbOKOnly, "Saisir les heures dans le champ
HrsLeger"
   End If
End Sub

    Every time you enter HrsHPLeger, and your ccPrive field = -1, the
MsgBox will fire.
    Bon Chance!
Signature

   hth
   Al Campagna
   Microsoft Access MVP
   http://home.comcast.net/~cccsolutions/index.html

   "Find a job that you love... and you'll never work a day in your life."

> Hi everybody,
> I receive an error message when I select HreHPLeger.
[quoted text clipped - 12 lines]
> End If
> End Sub
Céline Brien - 13 May 2008 15:00 GMT
Hello,
Thank you so much for your answer.
When the field ccPrive is true, the number of hours should be entered in the
field HrsLeger and not in the field HrsHPLeger.
So I would like to cancel the selection of the HrsHPLeger field and bring
the user to the field.HrsLeger.
To simplify, I used your code and I still receive the following error
message :
--------------------------------------------------------
L'expression Sur entrée entrée comme paramètre de la propriété de type
événement est à l'origine d'une erreur. Utilisation incorrecte de la
propriété.
* Le résultat de l'expression n'est pas le nom d'une macro, le nom d'une
fonction définie par l'utilisateur ou [Event Procedure].
* Une erreur a peut-être été commise lors de l'évaluation d'une fonction,
d'un événement ou d'une macro.
--------------------------------------------------------
Can you help ?
Céline

> Celine,
>    Whenever you receive an error message... please include that in your
[quoted text clipped - 30 lines]
>> End If
>> End Sub
Al Campagna - 13 May 2008 22:40 GMT
Celine,
   Use the AfterUpdate event of ccPrive...
   Again, *use your own control names* in the sample code...

Private Sub ccPrive_AfterUpdate()
   If ccPrive = True Then
       HrsLeger = [NoOfHours]
       Docmd.GoToControl "HrsLeger"
   End If
End Sub

   If the user selects True for ccPrive, HrsLeger will receive the value of
NoOfHours, and the user will be sent to the HrsLeger control.
Signature

   hth
   Al Campagna
   Microsoft Access MVP
   http://home.comcast.net/~cccsolutions/index.html

   "Find a job that you love... and you'll never work a day in your life."

> Hello,
> Thank you so much for your answer.
[quoted text clipped - 50 lines]
>>> End If
>>> End Sub
Céline Brien - 14 May 2008 15:30 GMT
Hello,
Thank you for your answer.
I am on the road today.
I will try your solution tomorrow and give you a feedback.
Many thanks again !
Céline

> Celine,
>    Use the AfterUpdate event of ccPrive...
[quoted text clipped - 63 lines]
>>>> End If
>>>> End Sub

Rate this thread:






 
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.