473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

3022 error + null value error

mseo
181 100+
hi,
I have developed a form for add new category using Ms-Access 2003 the first problem for me I got the error 3022 for no duplicating values and i have solved this one using this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub CategoryName_BeforeUpdate(Cancel As Integer)
  2.  
  3. Dim Answer As Variant
  4. Answer = DLookup("[CategoryName]", "tbl_Category", "[CategoryName] = '" & Me.CategoryName & "'")
  5. If Not IsNull(Answer) Then
  6. MsgBox "Hi-Tech sysadmin reports that Duplicate Category Name Found, " & "Please press ok and try again. ", vbCritical + vbOKOnly + vbDefaultButton1, "Hi-Tech sysadmin, Duplicate Category Found"
  7. Cancel = True
  8. Me.CategoryName.Undo
  9. End If
  10. End Sub
but after I used this i found that I can get record with its ID number but the category name is null
so I set the categoryname field to null
I got the same error of no duplicating when I use save plus the error of null valued how can make this form for adding new category integrated
it is now 12 days to trap this error
so if anyone could provide any help for solving this please submit
thank you in advance for any help you may provide me

--------------------------------------------------------------------------------
Oct 27 '09 #1
5 2831
Delerna
1,134 Expert 1GB
http://bytes.com/topic/visual-basic/...ry#post3520847

Identical question in 2 forums
Oct 27 '09 #2
Delerna
1,134 Expert 1GB
Really not sure what your question is....but

Do you have a key field (possibly categoryname) in the table and you are trying to insert a record with a value for that field that is already in the table ?

Duplicate values are not allowed in key fields


PS
Make sure when you post code that you use the code tags provided at the top of the posting window.

And if you can try and make it easily readable for us that would help us to help you
Oct 27 '09 #3
Delerna
1,134 Expert 1GB
something like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub CategoryName_BeforeUpdate(Cancel As Integer)
  2.    Dim Answer As Variant
  3.    Answer = DLookup("[CategoryName]", _
  4.                     "tbl_Category", _
  5.                     "[CategoryName] = '" & Me.CategoryName & "'")
  6.    If Not IsNull(Answer) Then
  7.       MsgBox "Hi-Tech sysadmin reports that Duplicate Category Name  Found, " _
  8.              & "Please press ok and try again. ",  _
  9.              vbCritical + vbOKOnly + vbDefaultButton1, _
  10.              "Hi-Tech sysadmin, Duplicate Category Found"
  11.       Cancel = True
  12.       Me.CategoryName.Undo
  13.    End If
  14. End Sub
  15.  
  16.  
You should write your own code something like that in your projects.
When trying to debug problems, readabilty can make all the difference
between a speedy fix and a hair pulling experience.

After reading the above code I see that you are trying to stop entry of duplicate categorynames, so I must have miss-understood your question with my first suggestion.

Don't forget, you can put breakpoints on each line of code.
That way, you can step through each line of code and watch what is happening.
Always helps me to find hard to find problems.
Oct 27 '09 #4
NeoPa
32,556 Expert Mod 16PB
Let us know how you get on with Delerna's last post. In case of interest, check out Debugging in VBA.
Oct 27 '09 #5
missinglinq
3,532 Expert 2GB
mseo, you also need to understand that Visual Basic and Visual Basic for Applications are not the same thing at all, despite their similar names and lineage! Many functions are interchangeable between the two but many, many things are not, even though they share identical names.

Welcome to Bytes! ;0)>
Oct 27 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jeff | last post by:
Hello all, I have an SQL Insert statement I'm trying to run via ExecuteNonQuery. It works fine so long as there are no nulls values. Here is the statement...(its a shortened version of what i...
1
by: excelleinc.com | last post by:
Hi, I'm trying to check if field contains NULL value in MSSQl 2000 database but keep receiving error. asp.net code: If Trim(HLSQLDSet.Tables("mfglinks").Rows(15).Item(0)) Is Null Then...
7
by: wrytat | last post by:
How do I check if an object is null in vb? I tried using IsDBNull but it doesn't work at all. It gives me this error when I try statement like If Not IsDBNull(theStock.WIPQty) Then: Object...
1
by: DaveC | last post by:
I have a simple one form VB.NET desktop app, that does a little threading like so mThread = New System.Threading.Thread(AddressOf DoSearch) mThread.Start() mThread has been decleared with the...
1
by: Smitty | last post by:
From the psql command line, I am having absolutely no problems inserting a NULL value into a date datatype field. When attempting to insert a NULL value via my Web app using SQL Relay, I am...
2
by: Jim McGivney | last post by:
In asp 2.0 I am trying to insert a row using a detailsview control connected to an accessDataSource. I get the error message below. I am having trouble identifing which data field is causing the...
2
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into...
0
by: michels287 | last post by:
With a single record in my table, I can use this code: Private Sub Command1_Click() Set cn = New ADODB.Connection cn.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data...
5
by: bkberg05 | last post by:
Hi - I have a combo box field on a form. The field is required (can't be left blank). Occassionally a user will come to the field and the combo box will not contain the desired record. So I added...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.