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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Find the error!

Status
Not open for further replies.

JackD4ME

Programmer
Jun 4, 2002
228
US
Can anyone see where the error is coming from?

Here is the code:
sTr="Insert Into Contacts ([First Name],[Last Name],Group,Address,City,State,Zip,Phone,Cell,Other,Fax,Email,Notes,Website) " & _
"Values ('" & Request("fname") & "', '" & _
Request("lname") & "', '" & _
Request("group") & "', '" & _
Request("address") & "', '" & _
Request("city") & "', '" & _
Request("state") & "', '" & _
Request("zip") & "', '" & _
Request("phone1") & Request("phone2") & Request("phone3") & "', '" & _
Request("cell1") & Request("cell2") & Request("cell3") & "', '" & _
Request("other1") & Request("other2") & Request("other3") & "', '" & _
Request("fax1") & Request("fax2") & Request("fax3") & "', '" & _
Request("email") & "', '" & _
Request("notes") & "', '" & _
Request("website") & "')"

And here is the result:
Insert Into Contacts ([First Name],[Last Name],Address,City,State,Zip,Phone,Cell,Other,Fax,Email,Notes,Website) Values ('Jimmy', 'Hoffa', '', 'Chicago', 'IL', '60033', '6305551212', '', '', '', '', 'Gangster', '')

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Field 'Contacts.Cell' cannot be a zero-length string.

/contacts.asp, line 28
 
Hi,
Perhaps you have the field in Contacts set to not allow Nulls..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Yes they were but that would generate a different error. I have changed them but am still getting the previous error.

Thanks ahead for the help.
 
Is the 'Allow zero length' property for the field set to No?

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I would maybe try something like the following
Code:
sTr="Insert Into Contacts ([First Name],[Last Name],Group,Address,City,State,Zip,Phone,Cell,Other,Fax,Email,Notes,Website) " & _
            "Values ('" & Request("fname") & "', '" & _
                          Request("lname") & "', '" & _
                          Request("group") & "', '" & _
                          Request("address") & "', '" & _
                          Request("city") & "', '" & _
                          Request("state") & "', '" & _
                          Request("zip") & "', " & _
                          [b]IIF(Request("phone1") = "",, "'" & Request("phone1") & Request("phone2") & Request("phone3") & "'") & ", " & _
                          IIF(Request("cell1") = "",, "'" & Request("cell1") & Request("cell2") & Request("cell3") & "'") & ", " & _
                          IIF(Request("other1") = "",, "'" & Request("other1") & Request("other2") & Request("other3") & "'") & ", " & _
                          IIF(Request("fax1") = "",, "'" & Request("fax1") & Request("fax2") & Request("fax3") & "'") & ", '" [/b]& _
                          Request("email") & "', '" & _
                          Request("notes") & "', '" & _
                          Request("website") & "')"
This will check, for example, whether the area code portion of the phone number is filled in, if it is then build the string for insertion, if it isn't a NULL will be inserted in its place. The above is assuming that you would have some check, be it client side or server side, that would require the user to either fill in all three portions of the phone fields or none at all for each different phone available.
 
I rebuilt the entire string late last night (Go SOX!) one field at a time and had a problem with 'group'. I needed to change that to 'organization'. Funny thing about this is I had removed that field during the day and it still had a problem. Anyway, it's fixed. Thanks for the help.

Jack :D
 
For the intellectually curious, GROUP is an ANSI SQL reserved word. You really should avoid using reserved words when you create tables, even though Access doesn't complain: it leads to this kind of problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top