|
-
Jan 16th, 2000, 08:04 PM
#1
Thread Starter
Member
If i want to save my values back into the database i get the following error:invalid use of null if one of my controls are empty.
I've tried everything?
What must i do?
I am using the following querry:
sql = "update Main set " & _
"Job_No = '" & txtJob.Text & "', " & _
"Cust = '" & txtCust.Text & "', " & _
"Site = '" & txtSite.Text & "', " & _
"Order_No = '" & txtOrder.Text & "', " & _
"Model = '" & txtModel.Text & "', " & _
"Prefix = '" & txtPrefix.Text & "', " & _
"Serial = '" & txtSerial.Text & "', " & _
"SMR = '" & txtSMR.Text & "', " & _
"DateOpen = '" & txtDateOpen.Text & "', " & _
"DateClosed = '" & txtDateClosed.Text & "', " & _
"DateStart & = '" & txtDateStart.Text & "', " & _
"DateEnd = '" & txtDateEnd.Text & "' , " & _
"Status = '" & chkStatus.Value & "' , " & _
"Remarks = '" & txtRemarks.Text & "'where idJob = " & _
intCurrJob
'execute the query
dbProgram.Execute sql
End If
-
Jan 16th, 2000, 08:12 PM
#2
Frenzied Member
change AllowZeroLength in the design of your table to "yes"
-
Jan 16th, 2000, 10:00 PM
#3
Thread Starter
Member
Thanks that helped allot.
But what must i do if it it a date/time or a number field where the allowzerolenght is not supported.
Any help?
-
Jan 16th, 2000, 10:13 PM
#4
Addicted Member
You can check in your values before updating or use decode function.
For sample:
decode(Text1.Text, NULL, '', Text1.Text)
------------------
smalig
[email protected]
http://vbcode.webhostme.com/
-
Jan 17th, 2000, 03:24 AM
#5
PowerPoster
I had this problem once and I found only Text fields caused it because the AllowZeroLength property was set to "No".
You should not have a problem with any other data type, but just to be sure, set fields that are Number, Date/Time etc to the following:
Required = No
Indexed = No
If they are indexed, then I think they have to have a value - this could be your problem.
Regards,
------------------
- Chris
[email protected]
If it ain't broke - don't fix it 
-
Jan 17th, 2000, 03:37 AM
#6
Hyperactive Member
I use a function that I made:
Function nonulls(s As Variant) As String
' - string = NoNulls(string)
' Checks to see if the string passed is null, if so then return "" else return
' the passed string. A wrapper for access stuff.
If IsNull(s) Or Len(s) = 0 Then
nonulls = ""
Else
nonulls = s
End If
End Function
and I call it -- StrField = nonulls(txtTextBox.text)
Basically, it replaces a Null with a blank. It works very well with databases.
-
Jan 17th, 2000, 12:03 PM
#7
Addicted Member
Sorry Corne, I have forgotten to specify it - DECODE function is a nonstandard SQL extension that is specific to Oracle. SQL Server's CASE function is a SQL extension that is part of the ANSI standard beyond Entry level and, therefore, not implemented in all database products.
In MS Access it's not working, I think.
What do you use?
------------------
smalig
[email protected]
http://vbcode.webhostme.com/
-
Jan 17th, 2000, 04:41 PM
#8
Thread Starter
Member
Thanks for all your help!!!!
But i cant seem to win ....
any more help please???
Thanks.
ps. I sorted out strings but struggle with empty date and value controls to write it back into a database.(access database)
-
Jan 17th, 2000, 05:31 PM
#9
Hyperactive Member
Code:
txt.Text = Iif(IsNUll(rs!MyField), "", rs!MyField)
-
Jan 17th, 2000, 10:37 PM
#10
Thread Starter
Member
I used the function netSurfer gave to me.
and it works very well.It converts a empty value to a zero.
Will it work with date values?
Is there no way that i can get empty textboxes.(value) not zero
Please help.
-
Jan 17th, 2000, 10:57 PM
#11
Hyperactive Member
It should work with any value at all. You can modify it to look for a certain date if that's what you mean.
I'm not sure what you mean by:
empty textboxes.(value) not zero
If you mean you want the value of an empty text box, which is normally null, to be something other than ZERO, you could always replace it with a space. Is that what you mean? If so, in the code:
If IsNull(s) Or Len(s) = 0 Then
nonulls = ""
Else
replace the "" with " " and that would work. If this isn't what you meant, please explain futher.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|