Really Urgent Help Needed 
Author Message
 Really Urgent Help Needed

I've got the following piece of code, which will save a record, but if it is
a duplicate it will comeback with a message, telling you to enter a
different order number, the problem is that even when I change the number to
one that is unique It keeps on giving the same error
Private Sub OrderSurveyNumber_AfterUpdate()
DoCmd.SetWarnings False
On Error Resume Next

If IsNull(Me![OrderSurveyNumber]) Then
Me!OrderSurveyNumber.Locked = False
Me!WorksOrderNumber.Enabled = False
Else
Me!OrderSurveyNumber.Locked = True
Me!WorksOrderNumber.Enabled = True
DoCmd.RunCommand acCmdSaveRecord
On Error GoTo Error_Message
End If

DoCmd.SetWarnings True

Error_Message:
MsgBox " The Order / Survey Number You Have Entered Belongs to Another
Order."
Me!OrderSurveyNumber.Locked = False
Me!WorksOrderNumber.Enabled = False
Me!OrderSurveyNumber.SetFocus

End Sub

Any help is most welcome
Thanks
Geoff



Mon, 13 Sep 2004 05:33:39 GMT  
 Really Urgent Help Needed
(Not entirely sure but) I think you assigned the Value of the Enabled
Property wrong way around.  If it is duplicated and you set the Enabled to
False, then your user won't be able to update the entry in the Control.

Check Access Help on Enabled Property so that you know what it means.

HTH
Van T. Dinh


Quote:
> I've got the following piece of code, which will save a record, but if it
is
> a duplicate it will comeback with a message, telling you to enter a
> different order number, the problem is that even when I change the number
to
> one that is unique It keeps on giving the same error
> Private Sub OrderSurveyNumber_AfterUpdate()
> DoCmd.SetWarnings False
> On Error Resume Next

> If IsNull(Me![OrderSurveyNumber]) Then
> Me!OrderSurveyNumber.Locked = False
> Me!WorksOrderNumber.Enabled = False
> Else
> Me!OrderSurveyNumber.Locked = True
> Me!WorksOrderNumber.Enabled = True
> DoCmd.RunCommand acCmdSaveRecord
> On Error GoTo Error_Message
> End If

> DoCmd.SetWarnings True

> Error_Message:
> MsgBox " The Order / Survey Number You Have Entered Belongs to Another
> Order."
> Me!OrderSurveyNumber.Locked = False
> Me!WorksOrderNumber.Enabled = False
> Me!OrderSurveyNumber.SetFocus

> End Sub

> Any help is most welcome
> Thanks
> Geoff



Mon, 13 Sep 2004 06:39:49 GMT  
 Really Urgent Help Needed
On Wed, 27 Mar 2002 21:33:39 -0000, "Geoff Codd"

Quote:

>I've got the following piece of code, which will save a record, but if it is
>a duplicate it will comeback with a message, telling you to enter a
>different order number, the problem is that even when I change the number to
>one that is unique It keeps on giving the same error
>Private Sub OrderSurveyNumber_AfterUpdate()

DO it in BeforeUpdate instead, and set Cancel to True.

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Mon, 13 Sep 2004 09:55:08 GMT  
 Really Urgent Help Needed
Well, since I don't see any way the the Error_Message code is skipped, I would
think you would always get an error message.

Try putting an Exit Sub statement before the Error_Message Line.

If IsNull(Me![OrderSurveyNumber]) Then
  ...
Else
  ...
End If

  DoCmd.SetWarnings True
  Exit Sub  '<--- Got this far so I don't need an error message

Error_Message:
  ...
  DoCmd.SetWarnings True
End Sub

Quote:

> I've got the following piece of code, which will save a record, but if it is
> a duplicate it will comeback with a message, telling you to enter a
> different order number, the problem is that even when I change the number to
> one that is unique It keeps on giving the same error
> Private Sub OrderSurveyNumber_AfterUpdate()
> DoCmd.SetWarnings False
> On Error Resume Next

> If IsNull(Me![OrderSurveyNumber]) Then
> Me!OrderSurveyNumber.Locked = False
> Me!WorksOrderNumber.Enabled = False
> Else
> Me!OrderSurveyNumber.Locked = True
> Me!WorksOrderNumber.Enabled = True
> DoCmd.RunCommand acCmdSaveRecord
> On Error GoTo Error_Message
> End If

> DoCmd.SetWarnings True

> Error_Message:
> MsgBox " The Order / Survey Number You Have Entered Belongs to Another
> Order."
> Me!OrderSurveyNumber.Locked = False
> Me!WorksOrderNumber.Enabled = False
> Me!OrderSurveyNumber.SetFocus

> End Sub

> Any help is most welcome
> Thanks
> Geoff



Mon, 13 Sep 2004 20:21:19 GMT  
 Really Urgent Help Needed
Thanks John, Thats done the trick



Quote:
> Well, since I don't see any way the the Error_Message code is skipped, I
would
> think you would always get an error message.

> Try putting an Exit Sub statement before the Error_Message Line.

> If IsNull(Me![OrderSurveyNumber]) Then
>   ...
> Else
>   ...
> End If

>   DoCmd.SetWarnings True
>   Exit Sub  '<--- Got this far so I don't need an error message

> Error_Message:
>   ...
>   DoCmd.SetWarnings True
> End Sub


> > I've got the following piece of code, which will save a record, but if
it is
> > a duplicate it will comeback with a message, telling you to enter a
> > different order number, the problem is that even when I change the
number to
> > one that is unique It keeps on giving the same error
> > Private Sub OrderSurveyNumber_AfterUpdate()
> > DoCmd.SetWarnings False
> > On Error Resume Next

> > If IsNull(Me![OrderSurveyNumber]) Then
> > Me!OrderSurveyNumber.Locked = False
> > Me!WorksOrderNumber.Enabled = False
> > Else
> > Me!OrderSurveyNumber.Locked = True
> > Me!WorksOrderNumber.Enabled = True
> > DoCmd.RunCommand acCmdSaveRecord
> > On Error GoTo Error_Message
> > End If

> > DoCmd.SetWarnings True

> > Error_Message:
> > MsgBox " The Order / Survey Number You Have Entered Belongs to Another
> > Order."
> > Me!OrderSurveyNumber.Locked = False
> > Me!WorksOrderNumber.Enabled = False
> > Me!OrderSurveyNumber.SetFocus

> > End Sub

> > Any help is most welcome
> > Thanks
> > Geoff



Tue, 14 Sep 2004 00:50:15 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Urgent - Really Need help with stored proc.

2. Search -- Really really need help

3. HELP: please i really need some help

4. HELP - Really, really simple printer questions

5. I really need help with writing a module

6. Write Conflict - I really need help BADLY

7. Need really help - Repeat: Error 3289 in CONSTRAINT clause

8. Really need help a bug with VS.Net and MaskEditBox

9. VB.net using msword object (Please really need help)

10. Really need help with the SYSTEM user vs NTFS rights

11. HELP : I REALLY NEED GWBASIC.COM

12. REALLY NEED HELP

 

 
Powered by phpBB® Forum Software