A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set Focus



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2006, 04:09 PM posted to microsoft.public.access.forms
Pam
external usenet poster
 
Posts: 131
Default Set Focus

I have a main form "fGeneralInfo" with subform "fWorkLog" and subform
"fWorkLogComments". When user enters comments to subform fWorkLogComments
and they don't enter their name and date in fWorkLog.CboTech and
fWorkLog.StartTime, I want a msg to pop up telling them to do so and to set
the focus to CboTech and then StartTime if both are not filled in. I have
the following code on BeforeUpdate of the subform "fWorkLogComments". I
have entered may combinations of SetFocus and can get nothing to work. The
message will pop up, but if user clicks ok at each one, they will eventually
leave the form. I really need to have Tech and StartTimes required for
these entries.

I would very much appreciate any help with this.
Pam

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Parent.fWorkLog!Tech) Then
Cancel = True
MsgBox "Please enter your name."

End If

If IsNull(Me.Parent.fWorkLog!StartTime) Then
Cancel = True
MsgBox "Please enter date for this comment in Start Time."

End If
End Sub


  #2  
Old December 21st, 2006, 04:18 PM posted to microsoft.public.access.forms
Daniel
external usenet poster
 
Posts: 1,017
Default Set Focus

In your table desing you should declare them as required fields.

Daniel





"Pam" wrote:

I have a main form "fGeneralInfo" with subform "fWorkLog" and subform
"fWorkLogComments". When user enters comments to subform fWorkLogComments
and they don't enter their name and date in fWorkLog.CboTech and
fWorkLog.StartTime, I want a msg to pop up telling them to do so and to set
the focus to CboTech and then StartTime if both are not filled in. I have
the following code on BeforeUpdate of the subform "fWorkLogComments". I
have entered may combinations of SetFocus and can get nothing to work. The
message will pop up, but if user clicks ok at each one, they will eventually
leave the form. I really need to have Tech and StartTimes required for
these entries.

I would very much appreciate any help with this.
Pam

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Parent.fWorkLog!Tech) Then
Cancel = True
MsgBox "Please enter your name."

End If

If IsNull(Me.Parent.fWorkLog!StartTime) Then
Cancel = True
MsgBox "Please enter date for this comment in Start Time."

End If
End Sub



  #3  
Old December 21st, 2006, 09:05 PM posted to microsoft.public.access.forms
Pam
external usenet poster
 
Posts: 131
Default Set Focus

Daniel,
Thanks for the reply. I tried this and received the message "Existing data
violates the new setting for the 'Required' property for field 'Tech'.
Pam

..
"Daniel" wrote in message
...
In your table desing you should declare them as required fields.

Daniel





"Pam" wrote:

I have a main form "fGeneralInfo" with subform "fWorkLog" and subform
"fWorkLogComments". When user enters comments to subform
fWorkLogComments
and they don't enter their name and date in fWorkLog.CboTech and
fWorkLog.StartTime, I want a msg to pop up telling them to do so and to
set
the focus to CboTech and then StartTime if both are not filled in. I have
the following code on BeforeUpdate of the subform "fWorkLogComments". I
have entered may combinations of SetFocus and can get nothing to work.
The
message will pop up, but if user clicks ok at each one, they will
eventually
leave the form. I really need to have Tech and StartTimes required for
these entries.

I would very much appreciate any help with this.
Pam

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Parent.fWorkLog!Tech) Then
Cancel = True
MsgBox "Please enter your name."

End If

If IsNull(Me.Parent.fWorkLog!StartTime) Then
Cancel = True
MsgBox "Please enter date for this comment in Start Time."

End If
End Sub





  #4  
Old December 22nd, 2006, 12:52 AM posted to microsoft.public.access.forms
Jacob
external usenet poster
 
Posts: 14
Default Set Focus

Pam,

Some of the records may have no data (Null) in that field. Make sure
that the field has data in *all* recrods before you change the setting
to "Required=Yes"

Further, I suggest that in addition to Reuired, set "Allow Zero Length"
to "No", if the option is there..

Regards
Jacob
..
Pam wrote:
Daniel,
Thanks for the reply. I tried this and received the message "Existing data
violates the new setting for the 'Required' property for field 'Tech'.
Pam

.
"Daniel" wrote in message
...
In your table desing you should declare them as required fields.

Daniel





"Pam" wrote:

I have a main form "fGeneralInfo" with subform "fWorkLog" and subform
"fWorkLogComments". When user enters comments to subform
fWorkLogComments
and they don't enter their name and date in fWorkLog.CboTech and
fWorkLog.StartTime, I want a msg to pop up telling them to do so and to
set
the focus to CboTech and then StartTime if both are not filled in. I have
the following code on BeforeUpdate of the subform "fWorkLogComments". I
have entered may combinations of SetFocus and can get nothing to work.
The
message will pop up, but if user clicks ok at each one, they will
eventually
leave the form. I really need to have Tech and StartTimes required for
these entries.

I would very much appreciate any help with this.
Pam

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Parent.fWorkLog!Tech) Then
Cancel = True
MsgBox "Please enter your name."

End If

If IsNull(Me.Parent.fWorkLog!StartTime) Then
Cancel = True
MsgBox "Please enter date for this comment in Start Time."

End If
End Sub




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:31 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.