Solved

IsEmpty() Function not evaluating properly

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 65
Vb.net 2008 2 56
Excel Vlookup to move data back to source. 4 84
VB 6.0 printer how to align 6 58
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now