Basically do a validation check before running the function.

So let's say you do:

if isnull (somevariable) = True then
msgbox "This cannot be blank"
else
#run your function

end if

Most of that problem occured is when you try to retieved a data from the database.
Here is some code that may help...

text1.text=iif(isnull(fieldname),"",thesamefieldname)

sir can i apply those code in "INSERT INTO STATEMENT?"
example:
dbTrans.Execute "INSERT INTO SI_Detail2 VALUES (" & Chr(34) & Text1(1).Text & Chr(34) & ", " & Chr(34) & rsT5!transtype & Chr(34) & ", " & Chr(34) & Text1(2).Text & Chr(34) & ", " & Chr(34) & Text1(0).Text & Chr(34) & ",'" & rsT5!Type & "', " & Chr(34) & rsT5!number & Chr(34) & ", #" & rsT5!tdate & "#, " & Chr(34) & rsT5!partcode & Chr(34) & ", " & rsT5!unitcost & ", " & varqty & ", " & Chr(34) & rsT5!type2 & Chr(34) & ", " & Chr(34) & rsT5!strno2 & Chr(34) & ", text1.text=iif(isnull(#" & rsT5!strdate2 & "#),"",#" & rsT5!strdate2 & "#)" ......

IIf(IsNull(!Process) = True, vbNullString, !Process)

Where (!Process) is a field from a table.

how can i put those code.. sir can u give an example..
this is the code im trying to debug.. hope find a solution... always thank you..

dbTrans.Execute "INSERT INTO SI_Detail2 VALUES (" & Chr(34) & Text1(1).Text & Chr(34) & ", " & Chr(34) & rsT5![DTR_Detail1.transtype] & Chr(34) & ", " & Chr(34) & Text1(2).Text & Chr(34) & ", " & Chr(34) & Text1(0).Text & Chr(34) & ",'" & rsT5!Type & "', " & Chr(34) & rsT5!number & Chr(34) & ", #" & rsT5!tdate & "#, " & Chr(34) & rsT5!partcode & Chr(34) & ", " & rsT5!unitcost & ", " & varqty & ", " & Chr(34) & rsT5!type2 & Chr(34) & ", " & Chr(34) & rsT5!strno2 & Chr(34) & ", #" & rsT5!strdate2 & "#, 0)"
the null there is rst5!strdate2...

dbTrans.Execute "INSERT INTO SI_Detail2 VALUES (" & Chr(34) & Text1(1).Text & Chr(34) & ", " & Chr(34) & rsT5![DTR_Detail1.transtype] & Chr(34) & ", " & Chr(34) & Text1(2).Text & Chr(34) & ", " & Chr(34) & Text1(0).Text & Chr(34) & ",'" & rsT5!Type & "', " & Chr(34) & rsT5!number & Chr(34) & ", #" & rsT5!tdate & "#, " & Chr(34) & rsT5!partcode & Chr(34) & ", " & rsT5!unitcost & ", " & varqty & ", " & Chr(34) & rsT5!type2 & Chr(34) & ", " & Chr(34) & rsT5!strno2 & Chr(34) & ", iif(isnull(#" & rsT5!strdate2 & "#),"",#" & rsT5!strdate2 & "#)"

try this...

sir i already try that one.. another error. message will appear...
it a syntax error in expression "##" sign....
when i did this one...>>

If IsNull(rsT5!strdate2) Then
dbTrans.Execute "INSERT INTO SI_Detail2 VALUES (" & Chr(34) & Text1(1).Text & Chr(34) & ", " & Chr(34) & rsT5![DTR_Detail1.transtype] & Chr(34) & ", " & Chr(34) & Text1(2).Text & Chr(34) & ", " & Chr(34) & Text1(0).Text & Chr(34) & ",'" & rsT5!Type & "', " & Chr(34) & rsT5!number & Chr(34) & ", #" & rsT5!tdate & "#, " & Chr(34) & rsT5!partcode & Chr(34) & ", " & rsT5!unitcost & ", " & varqty & ", " & Chr(34) & rsT5!type2 & Chr(34) & ", " & Chr(34) & rsT5!strno2 & Chr(34) & ",null)"
Else
dbTrans.Execute "INSERT INTO SI_Detail2 VALUES (" & Chr(34) & Text1(1).Text & Chr(34) & ", " & Chr(34) & rsT5![DTR_Detail1.transtype] & Chr(34) & ", " & Chr(34) & Text1(2).Text & Chr(34) & ", " & Chr(34) & Text1(0).Text & Chr(34) & ",'" & rsT5!Type & "', " & Chr(34) & rsT5!number & Chr(34) & ", #" & rsT5!tdate & "#, " & Chr(34) & rsT5!partcode & Chr(34) & ", " & rsT5!unitcost & ", " & varqty & ", " & Chr(34) & rsT5!type2 & Chr(34) & ", " & Chr(34) & rsT5!strno2 & Chr(34) & ", #" & rsT5!strdate2 & "#)"
End If
the error msg is (numbers of query values and destination are not the same.)

sir i get it.. theres a missing fields thats why...... anyways i encountered new problem... hehehe
here it is

"can't update. database or object is read only?"

tnx for the help...

This article has been dead for over six months. Start a new discussion instead.