Results 1 to 3 of 3
  1. #1
    VWSpeedyB is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Location
    Work in Center Valley, PA, live near Philadelphia, PA
    Posts
    25

    Asistance correcting an error in my Code

    Good morning Access Gurus!! I have implemented a line in my code to create or assign the next reference number (SNAP-R Reference), which is AlphaNumeric ($$$####) - this is a mandatory Format. However, I am receiving an error,

    "Syntax Error (missing operator) in query expression 'MAX(SNAP-R Reference)'."

    Here is my code:

    Function Enter_New_Commerce_License_Submission()


    On Error GoTo Enter_New_Commerce_License_Submission_Err
    DoCmd.Close acForm, "Commerce License Processing Menu"
    DoCmd.OpenForm "New Commerce License", acNormal, "", "", acEdit, acNormal
    DoCmd.GoToRecord acForm, "New Commerce License", acNewRec
    Nz (DMax("SNAP-R Reference", "Commerce Licenses", "SNAP-R Date=" & Year(Date))), 0 + 1


    Enter_New_Commerce_License_Submission_Exit:
    Exit Function
    Enter_New_Commerce_License_Submission_Err:
    MsgBox Error$
    Resume Enter_New_Commerce_License_Submission_Exit
    End Function


    What I would like to accomplish is this: When I click the button on my form to "Add a new Commerce License Application", the Form to enter the details opens, with the next SNAP-R Reference calculated and populated in its proper field. Is this an easy correction? I'm sorry if this is a basic question, but as my profile indicates, I have zero programming back-ground.


    THANK YOU!!!!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    here's some changes, you dont need the extra line to add new record...
    and you must assign the NZ function..

    Code:
    Function Enter_New_Commerce_License_Submission()
    On Error GoTo Enter_New_Commerce_License_Submission_Err
    
    
    DoCmd.Close acForm, "Commerce License Processing Menu"
    DoCmd.OpenForm "New Commerce License", , , , acFormAdd
    
    
    'THIS PERFORMS NO FUNCTION
    'YOU MUST ASSIGN IT
    X = Nz (DMax("SNAP-R Reference", "Commerce Licenses", "SNAP-R Date=" & Year(Date))), 0 + 1

  3. #3
    VWSpeedyB is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Location
    Work in Center Valley, PA, live near Philadelphia, PA
    Posts
    25
    Ranman256 - Thanks for the quick response. I was having some additional issues, and a couple of co-workers identified an issue because my Reference is alpha-numeric. They have provided addiitonal assistance with your advisement, and I'm almost there. I now have to get the Function to work with the button click from my main menu.

    Thank you, again!!

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

Similar Threads

  1. Stop VB Editor from auto-correcting
    By DubCap01 in forum Programming
    Replies: 5
    Last Post: 03-03-2015, 05:30 AM
  2. VBA Code Returning Error Run Time Error 3061
    By tgwacker in forum Access
    Replies: 2
    Last Post: 11-24-2013, 11:00 AM
  3. Need help correcting record count
    By Fivehole91 in forum Access
    Replies: 2
    Last Post: 05-15-2012, 05:15 PM
  4. Help for correcting Before Update
    By Pragmatic in forum Forms
    Replies: 11
    Last Post: 12-28-2011, 11:59 AM
  5. correcting typographical errors
    By aflashman in forum Access
    Replies: 1
    Last Post: 07-31-2011, 03:22 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