Results 1 to 13 of 13
  1. #1
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142

    Compile Error : Expected End of Statement

    Hello Everyone
    I am getting this error in the following query

    Private Sub WeekEndingbx_AfterUpdate()
    If WeekEndingbx >= date Then
    Me.CmboElement.RowSource = DoCmd.OpenQuery "Current_EditTimesheet_Element"
    Else
    Me.CmboElement.RowSource = Docmd.openQuery "Old_EditTimesheet_Element"
    End If


    End Sub
    How to rectify this?

  2. #2
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Bracket is missing in the cmdopen query.

    Hence the error.

    Private Sub WeekEndingbx_AfterUpdate()
    If WeekEndingbx >= date Then
    Me.CmboElement.RowSource = DoCmd.OpenQuery (Current_EditTimesheet_Element)
    Else
    Me.CmboElement.RowSource = Docmd.openQuery (Old_EditTimesheet_Element)
    End If
    End Sub





    Quote Originally Posted by Shamli View Post
    Hello Everyone
    I am getting this error in the following query

    Private Sub WeekEndingbx_AfterUpdate()
    If WeekEndingbx >= date Then
    Me.CmboElement.RowSource = DoCmd.OpenQuery "Current_EditTimesheet_Element"
    Else
    Me.CmboElement.RowSource = Docmd.openQuery "Old_EditTimesheet_Element"
    End If
    End Sub
    How to rectify this?

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Just

    Me.CmboElement.RowSource = "Current_EditTimesheet_Element"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Thank you!
    But somehow the query is not giving any data.
    is my if statement wrong?

    Quote Originally Posted by pbaldy View Post
    Just

    Me.CmboElement.RowSource = "Current_EditTimesheet_Element"

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Don't set RowSource with DoCmd.OpenQuery:

    Me.CmboElement.RowSource = "Current_EditTimesheet_Element"

    Ooops, now I see Paul already answered.

    Also, have to Requery combobox.

    Me.CmboElement.Requery

    STEP debug code.
    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
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Does the query return records otherwise? If it does and the combo doesn't show them, double check the column widths and count properties of the combo.

    I don't think I've ever had to add a requery after setting a row source.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Yes. The query returns value. The combo box doesn't. And I added the requery statement too.
    Still now value.

    Quote Originally Posted by pbaldy View Post
    Does the query return records otherwise? If it does and the combo doesn't show them, double check the column widths and count properties of the combo.

    I don't think I've ever had to add a requery after setting a row source.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Interesting. My code has it and expect it's there because wouldn't work otherwise.

    If you want to provide db for analysis follow instructions at bottom of my post.
    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.

  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
    Quote Originally Posted by Shamli View Post
    Yes. The query returns value. The combo box doesn't.
    Did you check the count and widths properties? Are they appropriate to what the query returns?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Yes. The count and column width properties are right.
    The weekendingbx is from a combo box and the data appears as you open the form.
    (It is carrying from the main form)

    Is it wrong to use the query in the after update event?



    Quote Originally Posted by pbaldy View Post
    Did you check the count and widths properties? Are they appropriate to what the query returns?

  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
    As mentioned in your other thread, I wouldn't do it this way. Having the data in different tables will be an ongoing headache. That said, no, the after update event should work. Are you sure the other query isn't getting selected, and if so does it return records? Seeing the db would certainly help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Yes you are right!
    I am keeping a single database and calling the values with a condition and its working.
    Thank you so much for your prompt replies and help.

    Quote Originally Posted by pbaldy View Post
    As mentioned in your other thread, I wouldn't do it this way. Having the data in different tables will be an ongoing headache. That said, no, the after update event should work. Are you sure the other query isn't getting selected, and if so does it return records? Seeing the db would certainly help.

  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
    Glad you got it working.
    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. Compile Error: Expected: list separator or )
    By Voodeux2014 in forum Programming
    Replies: 11
    Last Post: 04-21-2015, 10:23 AM
  2. Compile error: Expected end of statement
    By ritati in forum Macros
    Replies: 1
    Last Post: 12-05-2014, 05:33 AM
  3. Compile Error: Expected: list separator or )
    By jabadoojr in forum SQL Server
    Replies: 6
    Last Post: 10-22-2013, 01:55 PM
  4. Compile Error: Expected: list separator or )
    By Kirsti in forum Programming
    Replies: 2
    Last Post: 03-27-2012, 02:52 PM
  5. compile error: expected end of statement
    By RedGoneWILD in forum Programming
    Replies: 5
    Last Post: 07-29-2010, 10:12 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