Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AddNew only works when all textboxes are filled... 1

Status
Not open for further replies.

homesick

Programmer
Dec 5, 2001
55
CA
I have a form with several textboxes(agent name, date, cx name, ref#, product code ,dollar, cross sell, cross sell dollar) . If the User makes a sale they must fill in at least name, date...product code and dollar. Both cross sell fields do not have to be filled. So my problem is that when i submit the records to my db, it only works when all the fields are entered. Can someone help? Am i making sense?
 
In your database are the field's Required property set to True? If so, change it to False. If that doesn't work maybe just have a default value for all Textboxes of 0 rather than blank.
 
Thanks for the suggestion but the required properties are already set to false. Is there any other way besides entering a default value?
 
Without actually checking on it, it seems to me the problem is *null values. Try passing the value
Code:
txtName.Text & ""
(The value of the text in the textbox and a set of empty quotes). This should prevent a null value from being passed.
--------------
A little knowledge is a dangerous thing.
 
this is my code.....


Private Sub Command1_Click()

Dim tracker As ADODB.Recordset
Dim straname As String
Dim strdate As String
Dim strcname As String
Dim strrnumber As String
Dim strcode As String
Dim strdollar As String
Dim strxcode As String
Dim strxdollar As String
Dim strx2code As String
Dim strx2dollar As String
Dim strx3code As String
Dim strx3dollar As String
Dim strcalltype As String
Dim strcomments As String
Dim strpd As String
Dim strrpc As String


Dim ssql As String
Set tracker = CreateObject("adodb.recordset")

tracker.ActiveConnection = "provider=microsoft.jet.oledb.3.51;Data Source=a:\tracker.mdb"
ssql = "select * from tracker"
tracker.Open ssql, , adOpenStatic, adLockOptimistic, adExecuteNoRecords And adCmdText


straname = Combo5.Text
strdate = Text2.Text
strcname = Text5.Text
strrnumber = Text6.Text
strcode = Combo1.Text
strdollar = Text8.Text
strxcode = Combo2.Text
strxdollar = Text10.Text
strx2code = Combo3.Text
strx2dollar = Text12.Text
strx3code = Combo4.Text
strx3dollar = Text14.Text
strcalltype = Combo6.Text
strcomments = Text16.Text
strpd = Text3.Text
strrpc = Text4.Text


tracker.AddNew
tracker("aname") = straname
tracker("date") = strdate
tracker("cname") = strcname
tracker("rnumber") = strrnumber
tracker("code") = strcode
tracker("dollar") = strdollar
tracker("xcode") = strxcode
tracker("xdollar") = strxdollar
tracker("x2code") = strx2code
tracker("x2dollar") = strx2dollar
tracker("x3code") = strx3code
tracker("x3dollar") = strx3dollar
tracker("calltype") = strcalltype
tracker("comments") = strcomments
tracker("pd") = strpd
tracker("rpc") = strrpc
tracker.Update
MsgBox "Record added"


End Sub
 
Here's what I mean:
tracker("aname") = straname & ""
tracker("date") = strdate & ""
tracker("cname") = strcname & ""
tracker("rnumber") = strrnumber & ""
tracker("code") = strcode & ""
tracker("dollar") = strdollar & ""
tracker("xcode") = strxcode & ""
tracker("xdollar") = strxdollar & ""
tracker("x2code") = strx2code & ""
tracker("x2dollar") = strx2dollar & ""
tracker("x3code") = strx3code & ""
tracker("x3dollar") = strx3dollar & ""
tracker("calltype") = strcalltype & ""
tracker("comments") = strcomments & ""
tracker("pd") = strpd & ""
tracker("rpc") = strrpc & ""
--------------
A little knowledge is a dangerous thing.
 
IT worked....just a brian cramp......thanks a lot and SEASON'S GREETINGS!!!
 
Another solution would be to simply ignore any db fields for which the corresponding text box is empty.

Instead of:
recordset("field")=textbox_value

try:
If textbox.text <> &quot;&quot; Then recordset(&quot;field&quot;)=textbox_value
 
Thanks for the tip jbradley, but not all the fields on the form are textboxes. I have some combo boxes too. Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top