Solved

IsEmpty() Function not evaluating properly

Posted on 2006-07-13
5
300 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now