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  

Problem with Before update



 
 
Thread Tools Display Modes
  #1  
Old January 7th, 2008, 05:37 PM posted to microsoft.public.access.forms
scott04
external usenet poster
 
Posts: 197
Default Problem with Before update

I have the following code in my database:
Private Sub case_no_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("Case_no", "tbllawsuittracking", "Case_no = " &
Me.Case_No)) Then
Cancel = True
MsgBox "This is a duplicate", vbExclamation, "Duplicate value!"
End If
End Sub
Case number is a text field in the tblLawsuitTracking table. What i am
trying to do is prevent a duplicate case number upon entry when entering data
in a form. Problem is I just can't seem to get the code working properly.
Any suggestions on why this isn't working?
  #2  
Old January 7th, 2008, 06:34 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Problem with Before update

What is the data type of the field Case_no in tbllawsuittracking?
As written, it is expected to be a numeric data type. If it is text, you
need to enclose the compare value in quotes:

If Not IsNull(DLookup("Case_no", "tbllawsuittracking", "Case_no = '" &
Me.Case_No & "'")) Then


--
Dave Hargis, Microsoft Access MVP


"scott04" wrote:

I have the following code in my database:
Private Sub case_no_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("Case_no", "tbllawsuittracking", "Case_no = " &
Me.Case_No)) Then
Cancel = True
MsgBox "This is a duplicate", vbExclamation, "Duplicate value!"
End If
End Sub
Case number is a text field in the tblLawsuitTracking table. What i am
trying to do is prevent a duplicate case number upon entry when entering data
in a form. Problem is I just can't seem to get the code working properly.
Any suggestions on why this isn't working?

  #3  
Old January 7th, 2008, 06:46 PM posted to microsoft.public.access.forms
scott04
external usenet poster
 
Posts: 197
Default Problem with Before update

Dave,
Thank you. It was a text field

"Klatuu" wrote:

What is the data type of the field Case_no in tbllawsuittracking?
As written, it is expected to be a numeric data type. If it is text, you
need to enclose the compare value in quotes:

If Not IsNull(DLookup("Case_no", "tbllawsuittracking", "Case_no = '" &
Me.Case_No & "'")) Then


--
Dave Hargis, Microsoft Access MVP


"scott04" wrote:

I have the following code in my database:
Private Sub case_no_BeforeUpdate(Cancel As Integer)
If Not IsNull(DLookup("Case_no", "tbllawsuittracking", "Case_no = " &
Me.Case_No)) Then
Cancel = True
MsgBox "This is a duplicate", vbExclamation, "Duplicate value!"
End If
End Sub
Case number is a text field in the tblLawsuitTracking table. What i am
trying to do is prevent a duplicate case number upon entry when entering data
in a form. Problem is I just can't seem to get the code working properly.
Any suggestions on why this isn't working?

 




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 06:35 PM.


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