Results 1 to 10 of 10
  1. #1
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246

    Filter Form using VBA, Client did not like my previous Bookmarking solution.

    I have two sub forms on one modal form.

    Form 1 = Edit_Frame_Frm - Modal form that displays the following two forms side by site. See attached pic.

    Form 2 = Edit1_Frm

    Form 3 = Edit2_Frm

    The user will click a button on Edit1_Frm. The button will pick up the text field "DT_KEY_PIN" and filter the other form Edit2_FRM by the DT_KEY_PIN.

    On click:
    Dim stDTKEY As String

    stDTKEY = Me.DT_KEY_PIN

    Forms!Edit_Frame_FRM!Edit2_FRM.Form.FilterOn = False

    The above reference between the two forms is correct because I can watch the code turn off the filter on the other form.

    Forms!Edit_Frame_FRM!Edit2_FRM.Form.Filter = DT_KEY_PIN = stDTKEY

    I've tried all sorts of combinations of syntax on the above line but I just cant get it correct. It should filter Edit2_FRM showing the 2 corresponding DT_KEY_PIN records.


    Forms!Edit_Frame_FRM!Edit2_FRM.Form.FilterOn = True

    Thanks



    Fred
    Attached Thumbnails Attached Thumbnails Pins Screen 2.JPG  

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    It needs to be a string, so presuming a numeric data type:

    Forms!Edit_Frame_FRM!Edit2_FRM.Form.Filter = "DT_KEY_PIN = " & stDTKEY
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    Forms!Edit_Frame_FRM!Edit2_FRM.Form.Filter = DT_KEY_PIN = stDTKEY

    I am generally suspicious of syntax that has 2 = = signs without any " " bracketing....are you sure about that syntax??

  4. #4
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246

    Needs to be String.

    Quote Originally Posted by pbaldy View Post
    It needs to be a string, so presuming a numeric data type:

    Forms!Edit_Frame_FRM!Edit2_FRM.Form.Filter = "DT_KEY_PIN = " & stDTKEY
    I did not understand your opening statement, "It needs to be a string, so presuming a numeric data type:"

    It does need to be a string. Hence the dim stDTKEY as string. Although the field contains 14 numbers they sometimes have leading zeros. They are PINs Property Index Numbers so they are never calculated.

    I get a data type mismatch from your Forms line above.

  5. #5
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246
    I am sure about the syntax in that I am sure it is wrong. That is the statement I am trying to resolve. I have tried every combination I can think of apparently except the correct one. So I just stuck in what I ended up with.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    My $0.02....

    Since "DT_KEY_PIN" is a string, "stDTKEY" needs to be delimited.

    I would use:
    Code:
    Forms!Edit_Frame_FRM!Edit2_FRM.Form.Filter = "DT_KEY_PIN = '" & stDTKEY & "'"
    
    Forms!Edit_Frame_FRM!Edit2_FRM.Form.FilterOn = True

  7. #7
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246
    Steve: Thanks, that did it. I sure appreciate all the help. So thanks to all. I will mark this closed.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @Phred,

    Thank Paul. I just copied his post and added the single quotes....

  10. #10
    Phred is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    246

    In the way? I don't think so.

    Quote Originally Posted by pbaldy View Post
    I'll get out of the way.
    That thanks was meant for both of you, just poorly presented. You have helped me so many times and so generously as well.

    Apologies and Cheers. May your trick-or-treat bag be full.

    Fred

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

Similar Threads

  1. Replies: 21
    Last Post: 04-29-2015, 11:57 PM
  2. Thin client solution
    By Jasondk in forum Misc
    Replies: 1
    Last Post: 04-15-2013, 11:19 AM
  3. Replies: 1
    Last Post: 07-26-2011, 06:10 AM
  4. Replies: 3
    Last Post: 07-01-2011, 12:06 PM
  5. Replies: 3
    Last Post: 10-22-2010, 06:53 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