Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11

    Angry "Syntax error whit Record moving button, someone pls helpp!!!! asap, ty

    Hello, I just signed up for this forum while researching, and i come accross problem whit my code, i can't resolve it, so if someone see something i don't pls help.


    Code:
    Private Sub Command26_Click()
    
    Dim strSQL As String
    
    strSQL = "INSERT INTO [Prodata_djela] ([ID],[Ime djela],[Tehnika slikanja],[Godina_stvaranja],[Fotografija],[Umjetnik_id])"
    strSQL = strSQL + " SELECT [Umjetnicko_djelo].[ID],[Umjetnicko_djelo].[Ime djela],[Umjetnicko_djelo].[Tehnika_slikanja],[Umjetnicko_djelo].[godina_stvaranja],[Umjetnicko_djelo].[Fotografija],[Umjetnicko_djelo].[Umjetnik_ID]"
    strSQL = strSQL + " WHERE Prodata_djela.ID= ')" & Me.[ID] & ""
    
    
    DoCmd.SetWarnings False
    DoCmd.RunSQL (strSQL)
    DoCmd.SetWarnings True
    
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    strSQL = strSQL + " WHERE Prodata_djela.ID= ')" & Me.[ID] & ""

    loose that paren.
    " WHERE Prodata_djela.ID= " & Me.[ID]

  3. #3
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    Quote Originally Posted by ranman256 View Post
    strSQL = strSQL + " WHERE Prodata_djela.ID= ')" & Me.[ID] & ""

    loose that paren.
    " WHERE Prodata_djela.ID= " & Me.[ID]
    i still hvve some problem, http://prntscr.com/3pcztq

  4. #4
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    Quote Originally Posted by ranman256 View Post
    strSQL = strSQL + " WHERE Prodata_djela.ID= ')" & Me.[ID] & ""

    loose that paren.
    " WHERE Prodata_djela.ID= " & Me.[ID]
    I trie so hard to understand theese orders and functions,i am great at c++, but not at this, this is my actual 1st time, so...
    What thoes that 3rd line doo? Maybe ifyou can tell me that i can realise what the problem is...
    here is screenshot


    Click image for larger version. 

Name:	Screenshot_1.png 
Views:	11 
Size:	36.1 KB 
ID:	16673

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Are IDs numeric or text....I gave you numeric.

  6. #6
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    they are auto numbers, here is situation, i just have 2 tables, and when i sell item i want to

    click on the button and to move my record to sold items table, and i wanted the item to still have same id.
    i can upload u the bse if that can help.

  7. #7
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    cant do that. The source table you copy from if the INDEX is autonum....then the INDEX in the target table must be NUMBER.
    You cant copy autonumber to autonumber.

  8. #8
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    Ahh yeah that's right, thanks wery much man, ur the best

  9. #9
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    Man i still have syntax error that missing operator is killing me

  10. #10
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    put the line : debug.print strSQL , in the code right before: setwarnings false
    put a stop on the code here. (setwarnings)
    ctrl-G (to the debugger)
    copy the sql
    paste into a new query, then click design
    it might help you find the error.

  11. #11
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    is there any way to avoid this id thing, and put id on auto number?

  12. #12
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    The ID tells us what record to transfer. You dont need it to be stored as autonumber in the target table. The number wont change.

  13. #13
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    I don't know what happend, but now when i click the button program ask me for the item ID and do nothing

  14. #14
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    here:

    Click image for larger version. 

Name:	Screenshot_2.png 
Views:	7 
Size:	8.4 KB 
ID:	16674
    after i type the one i have on my item it does nothing.

  15. #15
    hamir007 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Posts
    11
    i realised it shall make new record by it's onw but it doesn't...

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 09-14-2014, 05:48 PM
  2. Replies: 30
    Last Post: 09-27-2013, 01:34 PM
  3. Replies: 2
    Last Post: 03-08-2013, 12:59 PM
  4. Replies: 4
    Last Post: 07-25-2012, 04:01 AM
  5. Replies: 13
    Last Post: 12-05-2011, 05:10 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