Results 1 to 9 of 9
  1. #1
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30

    Openig form to specific record.

    HelpMePlease.zipWhen trying to open a form to a specific record, a window pops up asking for the value of "txt_program_no"


    Isn't this supposed to be filled in with Me.lst_program_query upon opening form "frm_travelers_form"?
    I have even tried adding .Value to the end of Me.lst_program_query

    here is my VBA code...

    Code:
    Private Sub btn_open_form_Click()
        DoCmd.OpenForm "frm_travelers_form", , , "txt_program_no= " & Me.lst_program_query
        Me.Filter = True
    End Sub

  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
    53,631
    Is txt_program_no a field in frm_travelers_frm RecordSource?

    Is it a number or text type field?

    Why the Me.Filter = True line?
    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
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30
    txt_program_no is a field in the form frm_travelers_form. I want frm_travelers_form to open with record from Me.lst_program_query.

    I thought I had to have the filter set to true...?

  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
    53,631
    The filter line you have will be applied to the form with the button, not the form you are opening. The Me qualifier references the form that has the code.

    The WHERE argument in the OpenForm method should cause the form to be filtered.

    I don't know why the code is not finding txt_program_no.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30
    Quote Originally Posted by June7 View Post
    Is txt_program_no a field in frm_travelers_frm RecordSource?

    Is it a number or text type field?

    Why the Me.Filter = True line?
    txt_program_no is a text box bound to the table [tbl_travelers_programs]![tiw_program_no]
    It is a number field.

    Quote Originally Posted by June7 View Post
    The filter line you have will be applied to the form with the button, not the form you are opening. The Me qualifier references the form that has the code.

    The WHERE argument in the OpenForm method should cause the form to be filtered.

    I don't know why the code is not finding txt_program_no.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    Attached DB...thanks

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,631
    There is nothing attached to your post.

    The WHERE argument must reference a field name in the form being opened.

    DoCmd.OpenForm "frm_travelers_form", , , "tiw_program_no = " & Me.lst_program_query
    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
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30
    Quote Originally Posted by June7 View Post
    There is nothing attached to your post.

    The WHERE argument must reference a field name in the form being opened.

    DoCmd.OpenForm "frm_travelers_form", , , "tiw_program_no = " & Me.lst_program_query
    I attached it to my main post...I can see it...called "HelpMePlease.zip"

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,631
    Okay, I was only looking at latest post, never noticed it on first post if it was originally there.

    Did you try the code revision I suggested?
    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
    lynthel is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2013
    Posts
    30
    Quote Originally Posted by June7 View Post
    Okay, I was only looking at latest post, never noticed it on first post if it was originally there.

    Did you try the code revision I suggested?
    I just did...that did the trick...now to work out all the other bugs...thank you June7

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

Similar Threads

  1. Opening Form to a Specific Record
    By PPat in forum Forms
    Replies: 9
    Last Post: 04-24-2013, 08:47 PM
  2. Go To Specific Record on Form
    By burrina in forum Forms
    Replies: 4
    Last Post: 12-26-2012, 07:15 PM
  3. Help with opening form to specific record
    By manic in forum Programming
    Replies: 7
    Last Post: 09-18-2012, 08:44 PM
  4. Open form to specific record
    By Two Gun in forum Forms
    Replies: 7
    Last Post: 11-09-2011, 10:00 AM
  5. Open Form to Specific Record
    By batowl in forum Forms
    Replies: 1
    Last Post: 04-08-2011, 10:10 AM

Tags for this Thread

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