Results 1 to 10 of 10
  1. #1
    pbaker is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4

    Code Issue

    when trying to load a form there is some code that was programmed by someone else and its coming up with the following error invalid bracketing of name ' passengers'. but for some reason i cannot see the problem.



    i think i have found the code its running which is:

    sql3 = "SELECT [Title],[Firstname],[Surname],[Address1],[Address2],[Wchair] FROM [" & table & " Passengers] WHERE ([" & table & " Passengers].[Reg])=" & Reg & ";"

    can anyone see where the problem is.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Probably! What value is in the "table" variable? What is the actual name of the Table at which you will be looking?

  3. #3
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    that's because it IS invalid syntax.


    this should take away that specific error:


    Code:
    sql3 = "SELECT [Title],[Firstname],[Surname],[Address1],[Address2],[Wchair] FROM [" & table & "] " & _
    "WHERE ([" & table & "].[Reg])=" & Reg & ";"

    but the word "Passengers" is in your statement. what is that? gotta figure that out too. if it means nothing, or if it is part of the tablename, it should be included in the "table" variable anyway.


    by the way, "table" is a reserved word in the access program so name your variable something else. you're going to corrupt your access files by using "table" as variable names.

  4. #4
    pbaker is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4
    thank you for your help, like i say this database was created by an outside company some time ago, and now its been given to me to try and fix. thank you for your help in repsonce to ruralguys comments the table name was listed as table = passtab.value

    im going to also try and your suggestion help me with access and let you know how i get on. This database i think maybe needs re writing from the ground up.

    i have also worked out where the passengers bit comes from the table name was set to passtab.value which further up the code its says [passtab] = "abc" so it seems its looking for a table which does exist called abc passengers.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What value is in the passtab variable? What is the actual full name of the table?

  6. #6
    pbaker is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4
    i dont know why its been setup as variable, like i say i wasnt the one that designed it in the first place but the full table is abc passengers

  7. #7
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    Allan,

    do you want me to layoff? I'm sure you can handle this...you take it. I'll bow out now. good luck!

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Right after the sql3 = put a MsgBox sql3 and see what the string contains.

  9. #9
    pbaker is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2012
    Posts
    4
    I haven't done anything but the database seems to be working again now. Most odd thank you for your help and would you say it would be worth a rewrite

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by pbaker View Post
    I haven't done anything but the database seems to be working again now. Most odd thank you for your help and would you say it would be worth a rewrite
    I would not rewrite it unless absolutely necessary. BTW, if you did nothing to resolve the issue then I would expect the issue to reappear on its own.

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

Similar Threads

  1. Intermittant VBA Code Issue
    By eking002 in forum Forms
    Replies: 9
    Last Post: 07-10-2012, 02:20 PM
  2. Issue w/ VBA code for Opening/Closing Forms
    By need_help12 in forum Forms
    Replies: 5
    Last Post: 04-20-2012, 11:09 AM
  3. Code issue on Format of label
    By Gavroche in forum Reports
    Replies: 2
    Last Post: 09-14-2011, 06:19 AM
  4. Form Code issue
    By Gavroche in forum Forms
    Replies: 2
    Last Post: 09-10-2011, 09:19 PM
  5. Replies: 1
    Last Post: 03-18-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