Results 1 to 15 of 15
  1. #1
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30

    Syntax mistake? or Access hates me?

    Hi axe again. This time I have the theory that access hates me. how is it possible that I use a macro in a database but I cant use is it in the same exact conditions in another database? This time I'm trying to store in a table the result of the sum of to text fields inside a form using a macro. I successfully did it on another db as I said y even used the same names for the fields and the syntax is the same!! this is what I'm doing:



    The two fields of the form are called [Subtotal] and [Tax] they both contain this expressions:

    Subtotal -- =[sfrmOrder].[Form]![txtSubtotal] "this one is getting the value from a subform"

    Tax -- =[Subtotal]*0.16 "this one get the tax amount"

    I'm using a macro after the update of the Subtotal field I'm using the action SetValue with this arguments:

    [Forms]![Purchase Order].[Texto63], =[Forms]![Purchase Order].[Subtotal]+[Forms]![Purchase Order].[TAX]

    But all I get is a big "TYPE MISSMATCH" error 2950

    This mistake raised a question about the use of dots and bangs also may that be the syntax mistake? or does access really hates me? I hope you can help guys! thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Is that comma really in the code before the =?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    no well yes the thing is that access uses it to separate the element and the expression for this access. the comma appears when you copy it from the arguments column of the macro I don't know if I explained my self

  4. #4
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    *to separate the element and the expression for this action

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Sorry, I don't use macros. Do both of the source controls contain a numeric value? Is the target textbox really named "Texto63". Access would have defaulted to "Text63".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    this shows the properties for each field. IVA means Tax. If you need something else please tell me.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Can you post the db, or a representative sample that exhibits the error??
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    Here is my db

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    That's not the macro that's failing. It's the one in the got focus event of the DTM field. Try

    =DLookUp("[OT]","Requisiciones","[DTM] = Forms![Orden de Compra]![DTM_OC]")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    ok you are a wiz but how excuse me why one macro stepped into another? I'm terryble sorry for all the inconvenience but I'm deeply new for this type of programming. But I would really like to know what happened If you have the time of course Pbaldy you have been great help

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Not clear what you mean by stepping into another. That one runs as the form loads, because that textbox gets focus first. The syntax is wrong, so you get an error.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    I mean that the macro I'm using in the Subtotal field with the afterupdate event was sending the missmatch type error until you told me to change the one that was on the DTM with the focus event how is that possible

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I don't think your macro will ever be executed. You have it in the after update event of a calculated control (subtotal). The update events don't fire when the value is changed via calculation, only when the user changes the value. You probably want it either in the after update of a control in the subform that will be causing the subtotal to change, or perhaps the after update event of the subform itself. Depends on how you want it to flow.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    axess_nab is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    May 2010
    Posts
    30
    Pbaldy thanks for the advice I've changed it to update with the subform as you suggested Thanks! I'll be posting another problem but I just wanted to say this thread is SOLVED

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access 2007 syntax error in query
    By ivanver in forum Queries
    Replies: 3
    Last Post: 04-23-2011, 09:41 AM
  2. AutoExec Mistake
    By HawkGuru in forum Programming
    Replies: 1
    Last Post: 04-23-2011, 04:48 AM
  3. SQL syntax
    By dssrun in forum Queries
    Replies: 4
    Last Post: 04-15-2011, 01:06 PM
  4. Help with syntax
    By GWB in forum Queries
    Replies: 4
    Last Post: 01-26-2011, 03:33 PM
  5. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums