Results 1 to 12 of 12
  1. #1
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68

    How to edit post using button

    Hi!



    I would like to know how I can open a form (from a previous form) using a button belonging to the same post I want to open?..

    I e, I have a list of books in a form, and at every line I have an alter button that I want to use for opening another form so that I can edit that specific post. Doesn't sound too difficult to me, but I just can't figure out how to do =(

    Thanks

    Jonas

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Use WHERE CONDITION argument
    DoCmd.OpenForm "formname", , , "BookID=" & Me.BookID 'or whatever criteria is appropriate
    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.

  3. #3
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    What does all the ", , ," means?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Those are arguments I am not specifying. Defaults will be applied. See http://msdn.microsoft.com/en-us/libr...ffice.10).aspx
    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.

  5. #5
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    When I write this:

    DoCmd.OpenForm(frmComputerEdit, , ,)

    it says "compile error. Expected: expression". I've tried to search for what's missing, but I can't find anything. Does it want me to fill in the other values in the ()? But should they not be default if empty?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Don't use parentheses. See my example and the link article. Parentheses make VBA 'think' a function is invoked. Function must be one side of an expression.
    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
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    I have found a way to almost make it work... Now i write this:

    DoCmd.OpenForm "frmComputerEdit", , , , , , "ID = 'Me.ID'"

    But it just opens the first post in the table, no matter which posts' button I press. Me.ID, is that the command to call the ID on the specific post?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    You don't have the criteria in the WHERE CONDITION argument. You also have the quote marks wrong. Please follow the example provided and the referenced article.
    Last edited by June7; 10-24-2011 at 12:14 PM.
    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
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    This is what I've got now:

    DoCmd.OpenForm "frmComputerEdit", , , "ID = 'Me.ID'"

    but I get another error - nr 2501. The instruction OpenForm was aborted.

  10. #10
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    I solved the 2501 error. I want the criteria to look for an integer, and then I don't need the "" around Me.ID!

    But now when it works I found out that now I have to type which ID I want to open. I would like it to open that ID on wich the button is... How?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Per my original example, concatenate variables:

    DoCmd.OpenForm "frmComputerEdit", , , "ID = " & Me.ID
    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.

  12. #12
    PoorCadaver is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Oct 2011
    Posts
    68
    Huh, I tried before and it didn't work... But now it did...

    Thanks a lot!

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

Similar Threads

  1. Edit button not working
    By elamaranr in forum Access
    Replies: 0
    Last Post: 07-25-2011, 01:45 PM
  2. How to post a question on this forum
    By Matrix in forum Forum Suggestions
    Replies: 0
    Last Post: 05-29-2011, 08:59 PM
  3. Where can I post about a MS Access Job opportunity?
    By peterjohnkerner in forum Access
    Replies: 0
    Last Post: 08-03-2009, 08:30 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