Results 1 to 4 of 4
  1. #1
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291

    Syntax Error while calling sub: Expected: =

    I am sure this is a simple syntax error of some sort just havent been able to put my finger on the problem yet.



    I have a simple sub:
    Code:
    Sub sPosition(ctn As String, p1 As Integer, p2 As Integer)
        If IsNull(Me.Controls(ctn)) = False Then
            Me.Controls(ctn).Top = p1
            Me.Controls(ctn).Left = p2
        End If
    End Sub
    I try to call this sub with the code:
    Code:
    sPosition ("lblTo", 9950 ,8000)
    and it gives me the error
    Compile error:
    Expected: =

    I am confused why it wants an = sign, I removed the integers and it doesnt give me an error, but ofcourse doesnt work. Any help would be appreciated, thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try

    sPosition "lblTo", 9950 ,8000

    or

    Call sPosition ("lblTo", 9950 ,8000)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    cowboy is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    291
    both worked, can you explain why? Do () only work when you "Call" a sub?

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Basically; if you look at help on Call, it explains it better than I can.
    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. Syntax error
    By smikkelsen in forum Access
    Replies: 6
    Last Post: 04-28-2010, 09:38 AM
  2. Syntax Error
    By KLynch0803 in forum Programming
    Replies: 11
    Last Post: 02-04-2010, 01:45 AM
  3. Syntax error (comma) in query expression
    By KLynch0803 in forum Programming
    Replies: 3
    Last Post: 01-18-2010, 03:35 AM
  4. sql syntax error
    By SMAlvarez in forum Access
    Replies: 1
    Last Post: 03-12-2009, 09:43 PM
  5. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 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