Solved

IsEmpty() Function not evaluating properly

Posted on 2006-07-13
5
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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