Results 1 to 7 of 7
  1. #1
    Redm4n83 is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2023
    Posts
    4

    syntax error

    Hello



    Having issues with a syntax error of sorts.

    Please see attached file.

    If you open up form "Customers"
    Select anything from the combobox, Then select a customer and click on the "Edit Customer Info" button
    The correct form opens up and has no issues.

    However, If i do not select a customer, and go straight to the edit button it comes up with a syntax error.

    Sooooo. I have then copied and pasted this form to see what i can do to rectify the issue. Ive gone to Convert form macros to VBA, and it then has red text through the important part of the code as you will find in the form "Customers_Test"

    Ideally i would prefer the VBA code instead of the macro. This way i can add in an Ifnull to the code to stop all error and also allow me to modify a little more.
    Can someone please look at how i can rectify the red line issue in the "Customers_Test" form.

    Secondly.... This one is not too major for the time being. But if someone can assist with a Requery or refresh, As you will find that when the customer information is updated, (First or Last name) it is not updated automatically in the listbox when i close the Customer update form and return naturally back to the Customers list.
    Ive attempted the "OnCurrent" event, but this does not change anything unless i click on the actual form to make it current.


    Thanks in advance.
    Test.zip

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,942
    Not going to download and unzip a file, just for a few lines of code.
    Are you checking that the combo actually has a value? and how are you using it in code.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    1. Concatenation is not right. Correct code:

    Docmd.OpenForm "CustomerInfo_F", acNormal, "", "[ID]=" & Me.Inactive_Listbox, , acNormal

    DoCmd.OpenForm "CustomerInfo_F", acNormal, "", "[ID]=" & Me.All_Listbox, , acNormal

    2. Options. Have listbox form Requery its own listbox or have the customer edit form requery the listbox.

    Here's a trick to get familiar with. Open a form with acDialog and code execution from the calling form will suspend until the called form closes.

    So Customer form can have Me.Inactive_Listbox.Requery after DoCmd.OpenForm.

    I don't use macros but I expect acDialog can be specified in macro as well as VBA.
    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.

  4. #4
    Redm4n83 is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2023
    Posts
    4
    wow, other forums i have been on in the past have got super upset if the file was not attached to the thread.

    When being used as a macro created by Access it works fine, except for the error if nothing is selected from the listbox, however that part is not important.
    The code that was extracted from converting the macro to VBA is as follows

    Code:
    Private Sub Active_Edit_Button_Click()On Error GoTo Active_Edit_Button_Click_Err
    
    
    '  The line directly below is the one with error in it
        Docmd.OpenForm "CustomerInfo_F", acNormal, "", "[ID]=" [&Active_Listbox], , acNormal
    '  The line directly above is the one with error in it
    
    
    Active_Edit_Button_Click_Exit:
        Exit Sub
    
    
    Active_Edit_Button_Click_Err:
        MsgBox Error$
        Resume Active_Edit_Button_Click_Exit
    
    
    End Sub

  5. #5
    Redm4n83 is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2023
    Posts
    4
    fantastic.
    Thank you June7. Much appreciate your efforts in assisting.

    Thanks

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you read post 3?

    Often an issue can easily be resolved by posting the few lines of code of concern. Attaching a file as well never hurts.
    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.

  7. #7
    Redm4n83 is offline Novice
    Windows 11 Office 365
    Join Date
    Sep 2023
    Posts
    4
    yeah i read your post, and have replied. Thanks again
    Have added a reputation point for you

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

Similar Threads

  1. Replies: 15
    Last Post: 03-01-2021, 12:07 PM
  2. Replies: 6
    Last Post: 02-03-2020, 07:09 PM
  3. Replies: 5
    Last Post: 07-15-2019, 10:20 AM
  4. Replies: 6
    Last Post: 05-30-2012, 12:32 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