ei guys help me... im stock from this error tnx..

Recommended Answers

All 10 Replies

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.)

hmmm... try this one

'" & Format(rsT5!strdate2, "mm/dd/yyyy" & "'

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...

you might have opened the databsae in readonly mode.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.