close form only if certain criteria is tue.

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

Guest

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
In the On Close Event of the form put this
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if
 
Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Dennis said:
In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Maax said:
Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
Hi Dennis, thanks i will give that a try but i am pretty sure i tried that
already without success. I think i missed the cancel = true part though.

Dennis said:
In the On Close Event of the form put this
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Maax said:
Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
Yes, sorry, I meant the Unload event

Ofer Cohen said:
Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Dennis said:
In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Maax said:
Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




Ofer Cohen said:
Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Dennis said:
In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Maax said:
Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

Maax said:
hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




Ofer Cohen said:
Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Dennis said:
In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Maax said:
i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

Maax said:
hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




Ofer Cohen said:
Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
nope, still the same result. the form closes regardless of the fields below?
i thought things were going too well :-(

Ofer Cohen said:
If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Maax said:
i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

Maax said:
hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




:

Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
Can you post the code and the RowSource of the STATUS combo?

--
Good Luck
BS"D


Maax said:
ope, still the same result. the form closes regardless of the fields below?
i thought things were going too well :-(

Ofer Cohen said:
If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


Maax said:
i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

:

hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




:

Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
erm is this what you want?

row source---- SELECT Status.Status FROM Status;

where is the code part you require found?

very sorry i am a bit of a novice as you might have guessed. I have had
tremendous help from this group and my database has already far exceeded my
expectations.
I only get a chance to tweak and update once a week or less so things are
not fresh in my mind how i achieved them.


Ofer Cohen said:
Can you post the code and the RowSource of the STATUS combo?

--
Good Luck
BS"D


Maax said:
ope, still the same result. the form closes regardless of the fields below?
i thought things were going too well :-(

Ofer Cohen said:
If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

:

hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




:

Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
ahhhh, its def something to do with the status as when i remove this part of
the code and only check on BOM and LABOURHRS it works. Well it gives the
message then says action cancelled and remains in the form. Is it possible to
supress the action cancelled message?
All i need now is to work out why the status part is not working.

but its getting there.


Maax said:
erm is this what you want?

row source---- SELECT Status.Status FROM Status;

where is the code part you require found?

very sorry i am a bit of a novice as you might have guessed. I have had
tremendous help from this group and my database has already far exceeded my
expectations.
I only get a chance to tweak and update once a week or less so things are
not fresh in my mind how i achieved them.


Ofer Cohen said:
Can you post the code and the RowSource of the STATUS combo?

--
Good Luck
BS"D


Maax said:
ope, still the same result. the form closes regardless of the fields below?
i thought things were going too well :-(

:

If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

:

hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




:

Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
can i please ask a silly question? is the status case sensitive?
I am sure i already tried this sometime ago (had this prob a while)
I changed the if [status] = "engineered" to "Engineered" and it still never
worked, although i was not as far on as this.

I will try change it and will die if thats what the problems is?


Maax said:
erm is this what you want?

row source---- SELECT Status.Status FROM Status;

where is the code part you require found?

very sorry i am a bit of a novice as you might have guessed. I have had
tremendous help from this group and my database has already far exceeded my
expectations.
I only get a chance to tweak and update once a week or less so things are
not fresh in my mind how i achieved them.


Ofer Cohen said:
Can you post the code and the RowSource of the STATUS combo?

--
Good Luck
BS"D


Maax said:
ope, still the same result. the form closes regardless of the fields below?
i thought things were going too well :-(

:

If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

:

hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




:

Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
Ofer, i am so sorry for wasting your time. I changed it to "Engineered" and
it works fine apart from supressing the action cancelled message.



Maax said:
can i please ask a silly question? is the status case sensitive?
I am sure i already tried this sometime ago (had this prob a while)
I changed the if [status] = "engineered" to "Engineered" and it still never
worked, although i was not as far on as this.

I will try change it and will die if thats what the problems is?


Maax said:
erm is this what you want?

row source---- SELECT Status.Status FROM Status;

where is the code part you require found?

very sorry i am a bit of a novice as you might have guessed. I have had
tremendous help from this group and my database has already far exceeded my
expectations.
I only get a chance to tweak and update once a week or less so things are
not fresh in my mind how i achieved them.


Ofer Cohen said:
Can you post the code and the RowSource of the STATUS combo?

--
Good Luck
BS"D


:

ope, still the same result. the form closes regardless of the fields below?
i thought things were going too well :-(

:

If the STATUS is a combo box, then mybe the combo return the ID and not the
description

So it need to be the ID and not the description, the field that the combo is
bound to. (for example 1)

if [status] =1 and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

i dont know if it makes a difference but i am using a button on the for to
close the form (not the red X button, top right). Also when i enter the code,
run the form and go back to the code; the "end if" has turned yellow

:

hi guys, yes the BOM and LABOURHRS are numeric. i tried the code you supplied
Ofer but when i choose close the form closes regardless of the STATUS, BOM
and LABOURHRS.
The STATUS field is choosen from a drop down in that field. The BOM is a
currency and the labour is a simple number.




:

Hi Dennis,
The form close , doesn't have the option Close.

use the UnLoad event of the form.

if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

Also, if the fields bom and labourhrs are numeric you need to get rid of the
double quotes

if [status] ="engineered" and (Nz([bom],0) = 0 or Nz([labourhrs],0) =0) then
MsgBox "Your message"
Cancel = True
end if

--
Good Luck
BS"D


:

In the On Close Event of the form put thisc
if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0") then
MsgBox("Your message")
Cancel = True
end if

:

Hi All, i previously posted a very similar question in the forms group with
little success. I need to code the close form event so that the form does not
close if [status] ="engineered" and ([bom] = "0" or [labourhrs] ="0"). a
messgae will pop up to notify the user that the form is incomplete.

as usual any help greatly appreciated.
 
From your post, I think you better use the Before Update event of the form,
so the validation will apear even if you'll try moving to the next record
That way the message won't apear
 
Hi I changed to before update and the message does not appear :-)
however the form closes after my own message appears instead of staying open.
 
Back
Top