Results 1 to 4 of 4
  1. #1
    juanjose11 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    3

    Problems to find the chosen last name in a form

    Hi,

    I have the next code to show me a form by apellidos (last name). I mean I write the last name and then I click the command button OK to show me a form with that last name.

    Private Sub cboApellidos_AfterUpdate()
    ' Buscar el registro que coincida con el control.
    Me.RecordsetClone.FindFirst "[Apellidos] = '" & Me![cboApellidos] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub

    Private Sub cmdbusqapellidos_Click()


    On Error GoTo Err_cmdbusqapellidos_Click
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmUsuarios"
    stLinkCriteria = "[Apellidos]='" & Me![Apellidos] & "'"

    ' DoCmd.Close

    ' DoCmd.OpenForm stDocName, , , stLinkCriteria

    If IsNull([cboApellidos]) = True Then
    MsgBox (" Debe introducir un apellido")
    Else
    'DoCmd.Close
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    End If


    Exit_cmdbusqapellidos_Click:
    Exit Sub
    Err_cmdbusqapellidos_Click:
    MsgBox Err.Description
    Resume Exit_cmdbusqapellidos_Click
    End Sub


    The problema is that it works sometimes. Normally it shows the same last name. Someone can help me?

    Thanks a lot.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You dont need ANY code for this.

    you have your search form say: frmMain
    the box on the form: txtName
    enter name in box
    click button to open form say: frmClient

    the form is connected to query : qsClientData

    the query qsClientData looks at frmMain for the criteria under [name] field.
    select * from Clients where [name] = '" forms!frmMain!txtName

    Zero code.

  3. #3
    juanjose11 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    3
    Hi

    I have tried it but I haven't got it. It shows up nothing when I write a name in txtname and then I click on the button to open the form. Any help?

    Thanks a lot.

  4. #4
    juanjose11 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    3
    It already works. Cool!!

    Thank you.

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

Similar Threads

  1. Find First Sunday of month chosen function
    By Ruegen in forum Programming
    Replies: 28
    Last Post: 04-23-2014, 06:03 PM
  2. Replies: 1
    Last Post: 12-24-2012, 09:36 AM
  3. Replies: 7
    Last Post: 07-26-2011, 02:15 PM
  4. Generating report from fields chosen in a form
    By kroenc17 in forum Reports
    Replies: 19
    Last Post: 10-01-2010, 10:38 AM
  5. Replies: 6
    Last Post: 07-19-2010, 10:57 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