Results 1 to 5 of 5
  1. #1
    mrmims is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    53

    Issue with code opening another form to specific record ...

    Hello,

    I have a form, "frm_Axis_Info", which has an unbound text box, "Axis_Search", the user can type in an Axis Number and press enter. It opens another form "frm_Axes" to this specific record.

    It works great, except for the fact my users can not navigate through different records once "frm_axes" has opened. It only displays the record they were looking for and gives an error message ("You can't go to the specified record") if they try to navigate next or previous. There are hundreds of in "frm_Axes" but my code is limiting them only to the Axis Number they were looking for.

    What am I doing wrong?



    Code:
    Private Sub Axis_Search_AfterUpdate()
    
    
    If IsNull(Me.Axis_Search) Or Me.Axis_Search = "" Then
    
    
         MsgBox "Please enter an Axis Number"
         Me.Axis_Search.SetFocus
         Cancel = True
         Exit Sub
    End If
    
    
    If DCount("[AxisNumber]", "tbl_Axes", "AxisNumber = " & Me.Axis_Search) = 0 Then
         MsgBox "Please enter a Valid Axis Number"
         Me.[AxisNumber].SetFocus
         Cancel = True
         Exit Sub
    End If
    
    
    DoCmd.OpenForm "frm_Axes", , , "AxisNumber = " & Me.Axis_Search
    
    
    DoCmd.Close acForm, "frm_Axis_Info"
    
    
    End Sub
    Thank you for your help

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Nothing wrong, that is the correct behavior for the code.

    Why do you have to open another form to view record? Isn't it already available on the first form?
    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
    mrmims is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    53
    Hi and thank you for the help,

    "frm_Axis_Info" is a menu with many buttons leading to other reports and forms regarding information about the Axes.

    I have an unbound text box, "Axis_Search", on this form which allows to the user to enter in an Axis number, press enter, and open "frm_axes" directly to the specific Axis record.

    How can I change the code to have the "frm_Axes" still open to the specific record, BUT also allow the user to navigate between records and not just limit them to the record searched?

    Thank you

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Options:

    1. Maybe button on frm_Axes that removes the filter criteria from the Filter property and/or sets the FilterOn property to False

    2. Open frm_Axes without filter and use code that moves to the desired record - this is a bit more complicated and probably more than one way to accomplish.

    Don't open form with filter, pass criteria with OpenArgs
    DoCmd.OpenForm "frm_Axes", , , , , , Me.Axis_Search

    Code in frm_Axes Load or Open event to either set Filter and FilterOn properties (along with button in 1 to unset).

    Or if form opens with focus on AxisNumber control, try:
    DoCmd.FindRecord Me.OpenArgs, , , , , acCurrent

    Or if AxisNumber control cannot have focus, try:
    Me.RecordsetClone.FindFirst "AxisNumber=" & Me.OpenArgs
    If Not Me.RecordsetClone.NoMatch Then
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End If
    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
    mrmims is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    53
    Removing the filter was the way to go!!! Thank you so much. This is the code I use when opening the form "On Load".

    [Code]
    If Me.FilterOn = True Then
    Dim valFN As String
    valFN = Me.AxisNumber
    Me.FilterOn = False
    DoCmd.GoToControl "AxisNumber"
    DoCmd.FindRecord valFN
    End If
    [Code/]

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

Similar Threads

  1. Replies: 9
    Last Post: 10-09-2013, 08:45 AM
  2. Opening Form to a Specific Record
    By PPat in forum Forms
    Replies: 9
    Last Post: 04-24-2013, 08:47 PM
  3. Replies: 6
    Last Post: 11-13-2012, 04:29 PM
  4. Help with opening form to specific record
    By manic in forum Programming
    Replies: 7
    Last Post: 09-18-2012, 08:44 PM
  5. Replies: 1
    Last Post: 11-09-2010, 03:02 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