MsgBox entering the correct info

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I want to create a MsgBox pop up on the Form with a logic between two fields.
DateClosed and Disposition.

Here is the logic:
If there is a DateClosed entered, the user must fill out the Disposition
field.
I placed the code on Exit Event Procedure of Disposition field. If the user
place the cursor on Disposition field and tried to skip it without filling it
out, he gets the MsgBox telling to fill out the field, but the Msg pop up do
not shows up if the user skips the Disposition field and closes the form.

How can I make the user fill out the disposition field if he enters
DateClosed? Is there any way to check if the DateClosed is filled out and
Disposition is left blank the user has to fill out Disposition otherwise he
can not move to the next record.

Thank you
Bob
 
Use the BeforeUpdate event of the Form (not control).
Cancel the event if the data is not right.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
Cancel = True
MsgBox "No!"
End If
End Sub

If you want a code-free solution:
1. Open the table in design view.
2. Open the Properties box (View menu).
3. Beside the Validation Rule in the Properties box (not the one in the
lower pane of table design, which relates to a field), enter:
([DateClosed] Is Null) OR ([Disposition] Is Not Null)
 
Thank you for your help.
The code provided worked, but I want to place the cursor on the field
Disposition in order for user to fill out this field. When I write:
DoCmd.GoToControl "Dispposition" or Me![Disposition].SetFocus, I get an
error message :
Run time error '2110'
MAccess can't move the focus to the control Disposition.
What am I doing wrong please?
Thank you
Bob

Allen Browne said:
Use the BeforeUpdate event of the Form (not control).
Cancel the event if the data is not right.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
Cancel = True
MsgBox "No!"
End If
End Sub

If you want a code-free solution:
1. Open the table in design view.
2. Open the Properties box (View menu).
3. Beside the Validation Rule in the Properties box (not the one in the
lower pane of table design, which relates to a field), enter:
([DateClosed] Is Null) OR ([Disposition] Is Not Null)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob said:
Hi all,
I want to create a MsgBox pop up on the Form with a logic between two
fields.
DateClosed and Disposition.

Here is the logic:
If there is a DateClosed entered, the user must fill out the Disposition
field.
I placed the code on Exit Event Procedure of Disposition field. If the
user
place the cursor on Disposition field and tried to skip it without filling
it
out, he gets the MsgBox telling to fill out the field, but the Msg pop up
do
not shows up if the user skips the Disposition field and closes the form.

How can I make the user fill out the disposition field if he enters
DateClosed? Is there any way to check if the DateClosed is filled out and
Disposition is left blank the user has to fill out Disposition otherwise
he
can not move to the next record.

Thank you
Bob
 
Dunno.

You can move focus in Form_BeforeUpdate.

Is it possible that the control that has the focus has invalid data?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob said:
Thank you for your help.
The code provided worked, but I want to place the cursor on the field
Disposition in order for user to fill out this field. When I write:
DoCmd.GoToControl "Dispposition" or Me![Disposition].SetFocus, I get an
error message :
Run time error '2110'
MAccess can't move the focus to the control Disposition.
What am I doing wrong please?
Thank you
Bob

Allen Browne said:
Use the BeforeUpdate event of the Form (not control).
Cancel the event if the data is not right.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
Cancel = True
MsgBox "No!"
End If
End Sub

If you want a code-free solution:
1. Open the table in design view.
2. Open the Properties box (View menu).
3. Beside the Validation Rule in the Properties box (not the one in the
lower pane of table design, which relates to a field), enter:
([DateClosed] Is Null) OR ([Disposition] Is Not Null)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob said:
Hi all,
I want to create a MsgBox pop up on the Form with a logic between two
fields.
DateClosed and Disposition.

Here is the logic:
If there is a DateClosed entered, the user must fill out the
Disposition
field.
I placed the code on Exit Event Procedure of Disposition field. If the
user
place the cursor on Disposition field and tried to skip it without
filling
it
out, he gets the MsgBox telling to fill out the field, but the Msg pop
up
do
not shows up if the user skips the Disposition field and closes the
form.

How can I make the user fill out the disposition field if he enters
DateClosed? Is there any way to check if the DateClosed is filled out
and
Disposition is left blank the user has to fill out Disposition
otherwise
he
can not move to the next record.

Thank you
Bob
 
I want to prevent the user for leaving the disposition field blank. So if
they leave the disposition blank the MsgBox pops up telling them to fill out
this field, but the cursor is not in the field Disposition. If I say
'DoCmd.GoToControl "Disposition"
I' m getting the error message.This is the code. Why am I getting that error
message?

If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
MsgBox "Fill in Disposition Field if DateClosed is filled out !!"
Cancel = True
'DoCmd.GoToControl "Disposition"
End if

Thanks

Allen Browne said:
Dunno.

You can move focus in Form_BeforeUpdate.

Is it possible that the control that has the focus has invalid data?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob said:
Thank you for your help.
The code provided worked, but I want to place the cursor on the field
Disposition in order for user to fill out this field. When I write:
DoCmd.GoToControl "Dispposition" or Me![Disposition].SetFocus, I get an
error message :
Run time error '2110'
MAccess can't move the focus to the control Disposition.
What am I doing wrong please?
Thank you
Bob

Allen Browne said:
Use the BeforeUpdate event of the Form (not control).
Cancel the event if the data is not right.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
Cancel = True
MsgBox "No!"
End If
End Sub

If you want a code-free solution:
1. Open the table in design view.
2. Open the Properties box (View menu).
3. Beside the Validation Rule in the Properties box (not the one in the
lower pane of table design, which relates to a field), enter:
([DateClosed] Is Null) OR ([Disposition] Is Not Null)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Hi all,
I want to create a MsgBox pop up on the Form with a logic between two
fields.
DateClosed and Disposition.

Here is the logic:
If there is a DateClosed entered, the user must fill out the
Disposition
field.
I placed the code on Exit Event Procedure of Disposition field. If the
user
place the cursor on Disposition field and tried to skip it without
filling
it
out, he gets the MsgBox telling to fill out the field, but the Msg pop
up
do
not shows up if the user skips the Disposition field and closes the
form.

How can I make the user fill out the disposition field if he enters
DateClosed? Is there any way to check if the DateClosed is filled out
and
Disposition is left blank the user has to fill out Disposition
otherwise
he
can not move to the next record.

Thank you
Bob
 
No obvious reason, Bob.

I reguarly SetFocus to the problem control in Form_BeforeUpdate.

Therefore I'm asking if there may be a reason why Access won't let the focus
out of whatever control it is currently in.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Bob said:
I want to prevent the user for leaving the disposition field blank. So if
they leave the disposition blank the MsgBox pops up telling them to fill
out
this field, but the cursor is not in the field Disposition. If I say
'DoCmd.GoToControl "Disposition"
I' m getting the error message.This is the code. Why am I getting that
error
message?

If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
MsgBox "Fill in Disposition Field if DateClosed is filled out !!"
Cancel = True
'DoCmd.GoToControl "Disposition"
End if

Thanks

Allen Browne said:
Dunno.

You can move focus in Form_BeforeUpdate.

Is it possible that the control that has the focus has invalid data?


Bob said:
Thank you for your help.
The code provided worked, but I want to place the cursor on the field
Disposition in order for user to fill out this field. When I write:
DoCmd.GoToControl "Dispposition" or Me![Disposition].SetFocus, I get an
error message :
Run time error '2110'
MAccess can't move the focus to the control Disposition.
What am I doing wrong please?
Thank you
Bob

:

Use the BeforeUpdate event of the Form (not control).
Cancel the event if the data is not right.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
Cancel = True
MsgBox "No!"
End If
End Sub

If you want a code-free solution:
1. Open the table in design view.
2. Open the Properties box (View menu).
3. Beside the Validation Rule in the Properties box (not the one in
the
lower pane of table design, which relates to a field), enter:
([DateClosed] Is Null) OR ([Disposition] Is Not Null)


Hi all,
I want to create a MsgBox pop up on the Form with a logic between
two
fields.
DateClosed and Disposition.

Here is the logic:
If there is a DateClosed entered, the user must fill out the
Disposition
field.
I placed the code on Exit Event Procedure of Disposition field. If
the
user
place the cursor on Disposition field and tried to skip it without
filling
it
out, he gets the MsgBox telling to fill out the field, but the Msg
pop
up
do
not shows up if the user skips the Disposition field and closes the
form.

How can I make the user fill out the disposition field if he enters
DateClosed? Is there any way to check if the DateClosed is filled
out
and
Disposition is left blank the user has to fill out Disposition
otherwise
he
can not move to the next record.

Thank you
Bob
 
Of course, there could be other things, such as the control you are trying
to set focus to has its Enabled property set to No.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Allen Browne said:
No obvious reason, Bob.

I reguarly SetFocus to the problem control in Form_BeforeUpdate.

Therefore I'm asking if there may be a reason why Access won't let the
focus out of whatever control it is currently in.


Bob said:
I want to prevent the user for leaving the disposition field blank. So if
they leave the disposition blank the MsgBox pops up telling them to fill
out
this field, but the cursor is not in the field Disposition. If I say
'DoCmd.GoToControl "Disposition"
I' m getting the error message.This is the code. Why am I getting that
error
message?

If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
MsgBox "Fill in Disposition Field if DateClosed is filled out !!"
Cancel = True
'DoCmd.GoToControl "Disposition"
End if

Thanks

Allen Browne said:
Dunno.

You can move focus in Form_BeforeUpdate.

Is it possible that the control that has the focus has invalid data?


Thank you for your help.
The code provided worked, but I want to place the cursor on the field
Disposition in order for user to fill out this field. When I write:
DoCmd.GoToControl "Dispposition" or Me![Disposition].SetFocus, I get
an
error message :
Run time error '2110'
MAccess can't move the focus to the control Disposition.
What am I doing wrong please?
Thank you
Bob

:

Use the BeforeUpdate event of the Form (not control).
Cancel the event if the data is not right.

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull(Me.Disposition) And Not IsNull(Me.DateClosed) Then
Cancel = True
MsgBox "No!"
End If
End Sub

If you want a code-free solution:
1. Open the table in design view.
2. Open the Properties box (View menu).
3. Beside the Validation Rule in the Properties box (not the one in
the
lower pane of table design, which relates to a field), enter:
([DateClosed] Is Null) OR ([Disposition] Is Not Null)


Hi all,
I want to create a MsgBox pop up on the Form with a logic between
two
fields.
DateClosed and Disposition.

Here is the logic:
If there is a DateClosed entered, the user must fill out the
Disposition
field.
I placed the code on Exit Event Procedure of Disposition field. If
the
user
place the cursor on Disposition field and tried to skip it without
filling
it
out, he gets the MsgBox telling to fill out the field, but the Msg
pop
up
do
not shows up if the user skips the Disposition field and closes the
form.

How can I make the user fill out the disposition field if he enters
DateClosed? Is there any way to check if the DateClosed is filled
out
and
Disposition is left blank the user has to fill out Disposition
otherwise
he
can not move to the next record.

Thank you
Bob
 
Back
Top