Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems to find the chosen last name in a form

Status
Not open for further replies.

jjmadiaz

Technical User
Aug 29, 2005
2
ES
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 up the same last name. Can anyone help me?

Thanks a lot.
 
Should this:
Code:
stLinkCriteria = "[Apellidos]='" & Me![Apellidos] & "'"

be changed to this?
Code:
stLinkCriteria = "[Apellidos]='" & Me![[b][red]cbo[/red][/b]Apellidos] & "'"



Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top