Criteria not met, do not want form to go any farther

  • Thread starter P-chu via AccessMonster.com
  • Start date
P

P-chu via AccessMonster.com

I have a module that is just not working right:

Publkic Function FmUnload(MyForm As Form) As Integer
If MyForm![OrderNo] <> 0 And MyForm![Condition] = "complete" Then
MsgBox "The Condition is "complete", but the OrderNo is empty."
FmUnload = True
End If
End Sub
***********************************
On the Parent form I have:

Private Sub Form_Unload(Cancel As Integer)
Cancel = FormUnload(Me)
End Sub

I will get a message box if the criteria is not met, but it still goes on to
a new form when that button is clicked and I want it to not go any further
until the criteria is met.

Thanks for any advice you can give please.
 
P

P-chu via AccessMonster.com

I failed to mention to the below, that even if I put in an order number now,
it still gives me the message box, which I don't understand. Thanks.

P-chu said:
I have a module that is just not working right:

Publkic Function FmUnload(MyForm As Form) As Integer
If MyForm![OrderNo] <> 0 And MyForm![Condition] = "complete" Then
MsgBox "The Condition is "complete", but the OrderNo is empty."
FmUnload = True
End If
End Sub
***********************************
On the Parent form I have:

Private Sub Form_Unload(Cancel As Integer)
Cancel = FormUnload(Me)
End Sub

I will get a message box if the criteria is not met, but it still goes on to
a new form when that button is clicked and I want it to not go any further
until the criteria is met.

Thanks for any advice you can give please.
 
M

Michel Walsh

You posted something modified :

publKic instead of public

and you call the function

Form_Unload

but supplied the listing for

FmUnload


(not the same name)



I suggest you debug Step_by_step to see what is really going on in your real
case. I suspect that the variable Cancel is never modified (or re-modified
to false, later on).




Vanderghast, Access MVP



P-chu via AccessMonster.com said:
I failed to mention to the below, that even if I put in an order number
now,
it still gives me the message box, which I don't understand. Thanks.

P-chu said:
I have a module that is just not working right:

Publkic Function FmUnload(MyForm As Form) As Integer
If MyForm![OrderNo] <> 0 And MyForm![Condition] = "complete" Then
MsgBox "The Condition is "complete", but the OrderNo is empty."
FmUnload = True
End If
End Sub
***********************************
On the Parent form I have:

Private Sub Form_Unload(Cancel As Integer)
Cancel = FormUnload(Me)
End Sub

I will get a message box if the criteria is not met, but it still goes on
to
a new form when that button is clicked and I want it to not go any further
until the criteria is met.

Thanks for any advice you can give please.
 
P

P-chu via AccessMonster.com

Should of done copy and paste instead of relying on my terrible typing.
These were just typos. Sorry. Thank you for bringing it to my attention
(which is sometimes limited). Here is the corrections:

Public Function FmUnload(MyForm As Form) As Integer
If MyForm![OrderNo] <> 0 And MyForm![Condition] = "complete" Then
MsgBox "The Condition is "complete", but the OrderNo is empty."
FmUnload = True
End If
End Sub
***********************************
On the Parent form I have:

Private Sub Form_Unload(Cancel As Integer)
Cancel = FmUnload(Me)
End Sub

Michel said:
You posted something modified :

publKic instead of public

and you call the function

Form_Unload

but supplied the listing for

FmUnload

(not the same name)

I suggest you debug Step_by_step to see what is really going on in your real
case. I suspect that the variable Cancel is never modified (or re-modified
to false, later on).

Vanderghast, Access MVP
I failed to mention to the below, that even if I put in an order number
now,
[quoted text clipped - 21 lines]
 
J

John Spencer

That code still has syntax errors in it.
MsgBox "The Condition is "complete", but the OrderNo is empty."
should read
MsgBox "The Condition is ""complete"", but the OrderNo is empty."

As a guess, your test is incorrect. Perhaps you want the following.
ASSUMPTION: OrderNo is a number field and not a text field that contains
number characters.

If NZ(MyForm![OrderNo],0) = 0 And MyForm![Condition] = "complete" Then

End if

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

P-chu via AccessMonster.com said:
Should of done copy and paste instead of relying on my terrible typing.
These were just typos. Sorry. Thank you for bringing it to my attention
(which is sometimes limited). Here is the corrections:

Public Function FmUnload(MyForm As Form) As Integer
If MyForm![OrderNo] <> 0 And MyForm![Condition] = "complete" Then
MsgBox "The Condition is "complete", but the OrderNo is empty."
FmUnload = True
End If
End Sub
***********************************
On the Parent form I have:

Private Sub Form_Unload(Cancel As Integer)
Cancel = FmUnload(Me)
End Sub

Michel said:
You posted something modified :

publKic instead of public

and you call the function

Form_Unload

but supplied the listing for

FmUnload

(not the same name)

I suggest you debug Step_by_step to see what is really going on in your real
case. I suspect that the variable Cancel is never modified (or re-modified
to false, later on).

Vanderghast, Access MVP
I failed to mention to the below, that even if I put in an order number
now,
[quoted text clipped - 21 lines]
Thanks for any advice you can give please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top