Solved

IsEmpty() Function not evaluating properly

Posted on 2006-07-13
5
306 Views
Last Modified: 2010-04-30
I have tried IsNull and IsEmpty MULTIPLE ways within the following function.  However, it does not evaluate properly because I continually get the same response:  cannot be a zero length string.  Any suggestions as to what I'm missing?  I've assisgned 500 pts b/c extremely urgent that I finish this today.  
fyi:  opbene.value refers to ta textbox in the main form with initial value set to "".

sub addrec()
Dim form1, form2, form3, form4, form5, form6, form7, form8, form9, form10

form1 = main.UWRTR.value
form2 = main.PWD1.value
form3 = main.APPNAM.value
form4 = main.RELSHP.value
form5 = main.DTCODE.value
form6 = main.STATE.value
form7 = main.NOMEMB.value
form8 = main.PLAN.value
form9 = main.DEDAMT.value
form10 = main.OPBENE1.value
       If IsEmpty(form10) Then
         form10 = "NONE"
      Else
        form10 = main.OPBENE1.value
      End If

dim conn, rs, strsql

strsql = "INSERT INTO REFERRALS (UWRTR, REFNO, APPNAME, RELSHP, DTCODED, STATE, NOMEM, PLAN, DEDAMT, OPTBENE1, OPTBENE2, OPTBENE3, OPTBENE4) VALUES ("
strsql = strsql + "'" & form1 & "', '" & form2 & "', '" & form3 & "', '" & form4 & "', '" & form5 & "', '" & form6 & "', '" & form7 & "', '" & form8 & "', '" & form9 & "', '" & form10 & "', '" & form11 & "', '" & form12 & "', '" & form13 & "')"


ALERT(strsql)
Set conn = createobject("adodb.connection")
      conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\\server\folder\subfolder\TST.mdb"
   conn.Execute strsql,,129
   conn.Close:  Set conn = Nothing


Alert("Script is finished!")

End Sub


</script>
</body>
</html>
0
Comment
Question by:MoJeaux39
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
smidgie82 earned 500 total points
ID: 17100861
Hi MoJeaux39,

Try
If IsEmpty(main.OPBENE1.value) Then
    form10 = "NONE"
ElseIf len(main.OPBENE1.value) = 0 Then
    form10 = "NONE"
Else
    form10 = main.OPBENE1.value
   

Cheers!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17100980
I would try the len option. I see smidgie82 has also suggested that

But out of practice, I tend to trim also, so I wont use Len and do this instead

If Trim(main.OPBENE1.value )="" then form10 = "NONE" else form10 = main.OPBENE1.value





0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17101005
other things u could possibly try

If main.OPBENE1.value = Chr$(0)   'Empty string

If main.OPBENE1.value = vbNullString   'Empty string

0
 

Author Comment

by:MoJeaux39
ID: 17101382
Thank you all for the prompt response!   Smidgie82, I awarded you the pts since you replied first and the solution worked beautifully!   Thx!!
0
 
LVL 9

Expert Comment

by:smidgie82
ID: 17101396
Thank you.  Best of luck!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question