Results 1 to 15 of 15
  1. #1
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    73

    Error 2447 - There is an invalid use of the . (dot) or ! operator or invalid parentheses

    Hi all,
    I have a form with multiple Textboxes. One of the textbox "arrays" (as I call them), has a control source as below:
    =Val([Forms]![Frm_TyreForecast]![Frm_TyreForecastSubForm].[Form]![MM0_1])

    In the form's Load Event, I do some calculations, but I receive the error "2447 - There is an invalid use of the . (dot) or ! operator or invalid parentheses"

    Below the code

    Code:
    For i = 1 To 22 ===>   If Val(Me("QtyNeed" & i)) - Val(Me("SOH" & i)) < 0 Then
            Me("QtyPO" & i) = "0"
        Else
            Me("QtyPO" & i) = (Val(Me("QtyNeed" & i)) - Val(Me("SOH" & i)))
        End If
    Next i
    The line where the error occurs, is marked "===>" (Val(Me("QtyNeed" & i)))
    The second part of the If statement (Val(Me("SOH" & i)) ) is fine and has the correct value.

    If I put a physical number (ex. 2) into the control source of "QtyNeeded1", the calculations work fine, but of course the answers are wrong.



    Much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,958
    Does calc in QtyNeeded1 return correct result?

    This 'array' is on the main form?

    I can't see issue with code. Could provide your db for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Is it QtyNeed or QtyNeeded ?
    One or other is a typo?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    I don't think (Me("QtyNeed" & i)) is valid syntax.
    You could use Me.QtyNeed or Me!QtyNeed

    But perhaps you have a naming issue as Minty has asked.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,958
    Good eye Minty!

    Orange, it is valid syntax - shortened version of: Me.Controls("QtyNeed" & i)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    I saw that too but didn't post because I didn't know what the error result would be. Now that I've tested with that syntax, it is 2465 "Microsoft Access can't find..." and not 2447.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    73
    Hi all,
    Sorry for the delay.

    June7, the calculation in QtyNeed1, gives the Error 2447, but if I remove the control source and make the control source to a fix number (eg. 2) the calculation is done correctly, but the value will change as the data is analyzed, so I had a formula as the control source and then tried to do a calculation on the textbox. This seems to be the issue. Once I removed the formula from the textbox's control source, all calculations were running and is correct.

    Thank you for everybody's input.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    Not 100% sure of what your design structure is but it seems clear that a form/subform is involved.
    I was able to create the error with improper design in two ways.
    1) By using the subform reference syntax and pointing to the wrong place i.e. a control on the main form (thus pointing to the wrong form).
    2) By using the correct reference (path) but misspelling the control name.

    My point is that as long as the reference cannot be correctly evaluated by an expression I think you'd get that error. I wonder if that comes back to
    Is it QtyNeed or QtyNeeded ?
    One or other is a typo?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,958
    I don't see how formula in textbox would be an issue. Code is populating field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    The code refers to the control. The control has an invalid expression. The code barfs.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,958
    Oh, so back to the apparently bad control name reference. Got it. So how does removing calc from textbox get correct data saved to field since VBA needs calc value?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    Just a side note for consideration
    In the
    Code:
    Me("QtyPO" & i) = "0"
    This is assigning a text , NOT a numeric--- is that a contributing factor??

    Also, DC DS was it/is it QtyNeed or QtyNeeded???

  14. #14
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    So how does removing calc from textbox get correct data saved to field since VBA needs calc value?
    I think you're asking the OP because I have no idea. Without reviewing I have to wonder that if one is using vba, why not just do the calc in vba and assign it to the control but don't bind it to a field, otherwise a calc is being stored.
    @orange - except that the issue was eliminated by replacing the other portion of the expression with a static value? I did wonder about the text zero but didn't think it was relevant to the reported error.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742

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

Similar Threads

  1. Replies: 2
    Last Post: 12-05-2021, 06:17 AM
  2. Replies: 18
    Last Post: 02-26-2018, 03:42 PM
  3. Replies: 5
    Last Post: 07-22-2014, 06:58 AM
  4. Invalid Relational Operator Error
    By KelleyM in forum Queries
    Replies: 5
    Last Post: 11-08-2012, 10:53 AM
  5. Replies: 7
    Last Post: 08-28-2011, 02:07 PM

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