Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to avoid error message

piligrimpiligrim Member Posts: 14

How to avoid the error message

I have a function called CancelOrderOnExit which serves to return the goods and delete the order
in case the user suddenly decides to leave the process of issuing a document. The function actually works,
and performs the tasks or updating and deleting,but on the click event the following message appears:
Syntax error (missing operator) in query expression order.id
But if i press ok, then the functions works and gives the right results.
Is there any way to avoid the appearance of this error message?

The function looks like this:

Public Function CancelOrderOnExit()
Dim frm As Form
Set frm = Forms![FOrderInformation]
Dim StrSQL1 As String
Dim strSQL2 As String
Dim strSQL As String
'*******************************************
' 1 update the order before deleting it
......... coding

DoCmd.RunSQL StrSQL1
DoCmd.RunSQL strSQL2
DeleteOrder
frm.[ListOrders].Requery
frm.Requery
frm![current].Requery
End Function

Comments

  • ToniStorhannusToniStorhannus Member Posts: 6
    :
    : How to avoid the error message
    :
    : I have a function called CancelOrderOnExit which serves to return the goods and delete the order
    : in case the user suddenly decides to leave the process of issuing a document. The function actually works,
    : and performs the tasks or updating and deleting,but on the click event the following message appears:
    : Syntax error (missing operator) in query expression order.id
    : But if i press ok, then the functions works and gives the right results.
    : Is there any way to avoid the appearance of this error message?
    :
    : The function looks like this:
    :
    : Public Function CancelOrderOnExit()
    : Dim frm As Form
    : Set frm = Forms![FOrderInformation]
    : Dim StrSQL1 As String
    : Dim strSQL2 As String
    : Dim strSQL As String
    : '*******************************************
    : ' 1 update the order before deleting it
    : ......... coding
    :
    : DoCmd.RunSQL StrSQL1
    : DoCmd.RunSQL strSQL2
    : DeleteOrder
    : frm.[ListOrders].Requery
    : frm.Requery
    : frm![current].Requery
    : End Function
    :
    :
    You can try to do your functions within macro in which you also give the SetWarnings function like this:


    SetWarnings=No
    ...
    your function
    ...
    SetWarnings=Yes


    And you should be able to run that taks without warnings...

    Hope this helps.

    Toni Storhannus




  • splansingsplansing Member Posts: 140
    ***I don't know if you've fixed this already or not, but if you're in the form and you want to update the record, me.refresh always works. Kind of hard to tell what your code does though when you've got references to your own functions (DeleteOrder) and SQL statements that we can't see listed here.

    If you're in the form (which it sounds like you are from the Requery statement), try this:

    me.refresh
    dim rs as recordset
    set rs = me.recordsetclone
    rs.bookmark = me.bookmark
    rs.delete
    me.refresh


    This will delete the record you're looking at on the current form.

    : :
    : : How to avoid the error message
    : :
    : : I have a function called CancelOrderOnExit which serves to return the goods and delete the order
    : : in case the user suddenly decides to leave the process of issuing a document. The function actually works,
    : : and performs the tasks or updating and deleting,but on the click event the following message appears:
    : : Syntax error (missing operator) in query expression order.id
    : : But if i press ok, then the functions works and gives the right results.
    : : Is there any way to avoid the appearance of this error message?
    : :
    : : The function looks like this:
    : :
    : : Public Function CancelOrderOnExit()
    : : Dim frm As Form
    : : Set frm = Forms![FOrderInformation]
    : : Dim StrSQL1 As String
    : : Dim strSQL2 As String
    : : Dim strSQL As String
    : : '*******************************************
    : : ' 1 update the order before deleting it
    : : ......... coding
    : :
    : : DoCmd.RunSQL StrSQL1
    : : DoCmd.RunSQL strSQL2
    : : DeleteOrder
    : : frm.[ListOrders].Requery
    : : frm.Requery
    : : frm![current].Requery
    : : End Function
    : :
    : :
    : You can try to do your functions within macro in which you also give the SetWarnings function like this:
    :
    :
    : SetWarnings=No
    : ...
    : your function
    : ...
    : SetWarnings=Yes
    :
    :
    : And you should be able to run that taks without warnings...
    :
    : Hope this helps.
    :
    : Toni Storhannus
    :
    :
    :
    :
    :

  • Justin BibJustin Bib USAMember Posts: 0

    _______ / http://forcoder.org / free video tutorials and ebooks about ( Ruby, Visual Basic .NET, MATLAB, Assembly, Go, JavaScript, Scratch, PL/SQL, Visual Basic, PHP, R, Perl, C++, Python, Swift, Java, Delphi, C#, Objective-C, C Bash, Ada, Julia, Logo, Kotlin, Lisp, Alice, Scheme, SAS, FoxPro, Dart, Fortran, Clojure, Transact-SQL, Rust, ABAP, Awk, COBOL, Lua, Hack, F#, Apex, Prolog, Erlang, D, ML, Scala, Crystal, LabVIEW, VBScript ) ___________

Sign In or Register to comment.