Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Apr 2007
    Posts
    81

    Unanswered: I want show one specific record only.

    Hi for everyone

    I have form continues records, when I double click on the record to open detail form,
    The detail form open with two records or more which the same name,
    I want show one specific record only.

    tray open the main form and click on First name record.

    thanks
    Attached Files Attached Files

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    To restrict to one specific record, use the ID field in your wherecondition instead of the first name field.
    Paul

  3. #3
    Join Date
    Apr 2007
    Posts
    81
    Hi pbaldy

    please if you can solve it or upload attach example.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Did you even try?

    DoCmd.OpenForm EmpDetailForm, , , "ID=" & Me.ID
    Paul

  5. #5
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    SamI2,

    Dim EmpDetailForm As String
    Dim declate2 As String
    EmpDetailForm = "EmpDital"
    DoCmd.OpenForm EmpDetailForm, , , "[first]=forms![MainForm]![EmpFrm]![Text2]"

    You need to put the ID field in the EmpFrm detail section and then

    Should be...
    'Dim EmpDetailForm As String <- not needed
    'Dim declate2 As String <- not needed
    'EmpDetailForm = "EmpDital" <- not needed
    DoCmd.OpenForm "EmpDital", , , "[ID]= " & me!ID & " "
    or as Paul showed above...
    DoCmd.OpenForm EmpDetailForm, , , "ID=" & Me!ID

    As a note, keep in mind that you don't want to open the detail form based on using the first name as criteria (consider that there might be 2 or 3 Paul's as a first name.) Unless you specifically want to open the detail form for all user's whose first name is Paul. Otherwise, add the ID field to the EmpFrm form and use ID as criteria to open the EmpDital form.
    Last edited by pkstormy; 11-06-07 at 16:36.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  6. #6
    Join Date
    Apr 2007
    Posts
    81
    Hi

    I used both codes but still the same problem.

  7. #7
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Post the code you tried. I tested what I posted and it worked perfectly in your application.
    Paul

  8. #8
    Join Date
    Apr 2007
    Posts
    81
    I used this code:

    Private Sub Lnam_DblClick(Cancel As Integer)
    DoCmd.OpenForm "EmpDital", , , "[ID]= " & Me!ID & " "
    End Sub

  9. #9
    Join Date
    Nov 2007
    Posts
    15
    hmm....some syntax learning

  10. #10
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Well, here's your sample back.
    Attached Files Attached Files
    Paul

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Paul,

    Not sure if it's worth noting but the . verses the ! has given me problems with some mdb's. Your example works great using the . but other mdb's it doesn't work using the .

    SamI2, it also probably doesn't make a difference but I noticed you don't have the ID field on either of the forms.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  12. #12
    Join Date
    Apr 2007
    Posts
    81
    Hi pbaldy and pkstormy

    I use the code for Pbaldy example and I copy the code, the Strange is still the problem.

    you can check the attach.
    Attached Files Attached Files

  13. #13
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I checked your attached file and it works fine for when you click on the Last name. It does exactly what you want which is open up the detailed form based on the specific ID. You need to put in the same code for the First name. What is the problem?
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  14. #14
    Join Date
    Apr 2007
    Posts
    81
    Hi

    please when you open the detail form, tray click on the first name because the same name with the second record

    see the picture to know what I want exactly.

    thanks
    Attached Thumbnails Attached Thumbnails One record for pbaldy sample.bmp   my trying.bmp  

  15. #15
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Did you read Paul's response? You need the same code for first name as for last name. Copy/Paste.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •