Results 1 to 8 of 8
  1. #1
    budchevy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    15

    open form code question

    Dealing with someone else's VBA code here , but here is what I have:

    Private Sub RvIIA_Click()
    On Error GoTo Err_RvIIA_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "FrmIIA"

    stLinkCriteria = "[Auditor]=" & "'" & Me![Auditor] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria



    Exit_RvIIA_Click:
    Exit Sub
    Err_RvIIA_Click:
    MsgBox Err.Description
    Resume Exit_RvIIA_Click

    End Sub

    I need this sub to open the form "FrmIIA" and sort the records by date for the "auditor" in question..

  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,820
    Set the sort order in the form's RecordSource query or if the RecordSource is just a table, use the form OrderBy and OrderByOnLoad properties.
    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
    budchevy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    15
    this VBA code is from a command button inside the form.. Not sure how to set the sort order other than with code, which i suck at

  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,820
    The sort order can be specified within an Access query or in the properties of the form. Neither involve code.
    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
    budchevy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    15
    The form has 8 command buttons inside it. The code for these buttons refer to other forms, all of which do different things. I don't see how I can set the sort order inside the form?

  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,820
    Those properties would be set in the form or report that is being opened. If you want a different sort order at run time, then modify the property with code. Macros might be able to do these actions, but I use only VBA.

    If you want to build db with advanced features, need to get comfortable with coding. Start with http://office.microsoft.com/en-us/ac...010341717.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.

  7. #7
    budchevy is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2012
    Posts
    15
    I learned VB 15 years ago, I'm comfortable messing around with other peoples code. I was just looking for someone to help me out with a quick fix.. thought that was the purpose of the forums?

  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,820
    I have given you possible 'quick fix' options but really not much info to work with. What do the 8 buttons have to do with the sort order of the form "FrmIIA"?

    Suggestions are:

    1. set sort order in query that form is bound to
    2. set sort criteria in the form SortBy property
    3. use code to set SortBy property

    You said your coding skills were weak so I referenced a resource to improve.

    Unless you want to provide the project for analysis, that's all I can offer.
    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.

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

Similar Threads

  1. VB Code to open a form?
    By HeadGasket in forum Access
    Replies: 1
    Last Post: 01-24-2012, 08:26 PM
  2. Question access 2010 macro & open form
    By Grek in forum Access
    Replies: 3
    Last Post: 10-30-2011, 01:58 PM
  3. Form Code refresh on open
    By mseeker22 in forum Forms
    Replies: 2
    Last Post: 07-08-2011, 12:35 AM
  4. Replies: 21
    Last Post: 02-14-2011, 02:51 PM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 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