| | |
Null errors in simple database, why?
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2008
Posts: 20
Reputation:
Solved Threads: 0
If I create a database that has 3 fileds per record; String1, String2 & ResultString. I want the user to enter in the first 2 strings then the program creates ‘ResultString’ by adding the String2 to String 1 itself.
Ie if you enter Big as String1 and Cat as String2 I want ResultString to be BigCat.
I guess I create a sub that is triggered by a change in either 1 of the 2 user entered fields then execute some code as below:
But I get a Null error. What am I doing wrong?
Many thanks for any help.
Ie if you enter Big as String1 and Cat as String2 I want ResultString to be BigCat.
I guess I create a sub that is triggered by a change in either 1 of the 2 user entered fields then execute some code as below:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Data1.Recordset.Fileds(“ResultString”) = Data1.Recordset.Fileds(“String1”) + Data1.Recordset.Fileds(“String2”)
But I get a Null error. What am I doing wrong?
Many thanks for any help.
hi. i think it is much better that you will use the values of the string1 and string2 for the value of Data1.Recordset.Fileds(“ResultString”). You have not yet save any the data so your values for Data1.Recordset.Fileds(“String1”) and Data1.Recordset.Fileds(“String2”) are both null.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Data1.Recordset.Fileds(“ResultString”) = string1 + String2
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Data1.Recordset.Fileds(“ResultString”) = Data1.Recordset.Fileds(“String1”) + Data1.Recordset.Fileds(“String2”)
AUGXIS is correct. If youre trying to save the records in the database use the existing data...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
With Data1.Recordset .Addnew .Fields("String1") = "Big" .Fields("String2") = "Cat" .Fields("ResultString") = "Big" & "Cat" .Update End With or... With Data1.Recordset .Addnew !String1 = "Big" !String2 = "Cat" !ResultString = "Big" & "Cat" .Update End With
Last edited by jireh; Oct 14th, 2008 at 9:14 am.
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
hell_tej it cant be... null value will be returned from
because it's a new record and not yet inserted/saved in the database.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Data1.Recordset.Fileds(“String1”) & "" + Data1.Recordset.Fileds(“String2”) & ""
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
•
•
Join Date: Oct 2008
Posts: 20
Reputation:
Solved Threads: 2
There's another problem you can run into that will give a Null error. If one field is empty there is nothing to concatenate. So how do you check for that? If you read the textbox into a text variable and check for Null, it will never be Null because it is a string type. IsNull only works with variants, I think. So assign the .text from the textbox to a variant and use IsNull. If the .text is not Null, you can use it as-is, or re-assign it to a string variable. If it IsNull, replace it with "" and go on.
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (PHP)
- Fatal error: require once (PHP)
- Using OpenGL in Visual C++: Part I (Game Development)
- Need help resolving errors for a simple program (Java)
- AJAX generated <select> and FIREFOX (JavaScript / DHTML / AJAX)
- URGENT: JSP - StackOverFlow Error (JSP)
- Can Someone please check my project & comment/tips (C)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: String Handling
- Next Thread: Splitting up Strings
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






