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

need some sort of error handler

Status
Not open for further replies.

honeypot

Technical User
Mar 6, 2001
147
GB
i have a textbox which is connected to four address fields in a database. If the user doesnt enter 4 lines of address then i understand my program will crash!! How do i work around this? heres a bit of my code that splits the textbox:

Dim mySplit As Array
mySplit = Split(txtAddress.Text, vbCrLf)

T = T & "address_1 = '" & mySplit(0) & "',"
T = T & "address_2 = '" & mySplit(1) & "',"
T = T & "address_3 = '" & mySplit(2) & "',"
T = T & "address_4 = '" & mySplit(3) & "',"
 
Hi,

See if there are nulls allowed in the address fields, then if the user doesn't enter an address:

If trim(mySplit(0)) = "" then T = , NULL" else....

I've found that it's best to put your commas at the beginning of the string instead of the end, too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top