Link to home
Start Free TrialLog in
Avatar of MoJeaux39
MoJeaux39

asked on

IsEmpty() Function not evaluating properly

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>
ASKER CERTIFIED SOLUTION
Avatar of smidgie82
smidgie82
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rockiroads
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





other things u could possibly try

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

If main.OPBENE1.value = vbNullString   'Empty string

Avatar of MoJeaux39
MoJeaux39

ASKER

Thank you all for the prompt response!   Smidgie82, I awarded you the pts since you replied first and the solution worked beautifully!   Thx!!
Thank you.  Best of luck!