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.connec tion")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\\server\fold er\subfold er\TST.mdb "
conn.Execute strsql,,129
conn.Close: Set conn = Nothing
Alert("Script is finished!")
End Sub
</script>
</body>
</html>
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.connec
conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\\server\fold
conn.Execute strsql,,129
conn.Close: Set conn = Nothing
Alert("Script is finished!")
End Sub
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
other things u could possibly try
If main.OPBENE1.value = Chr$(0) 'Empty string
If main.OPBENE1.value = vbNullString 'Empty string
If main.OPBENE1.value = Chr$(0) 'Empty string
If main.OPBENE1.value = vbNullString 'Empty string
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!
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