ctl.Name

  • Thread starter Thread starter john
  • Start date Start date
J

john

I have the following event procedure set to do a search on any text box I am
on through a Command Button Click, bur I need to have the "ControlSource"
returned for use in the "strCriteria" but do not know the exact Code to
retrieve it? It is basicaly the Field Name of the TextBox.

Private Sub cmdFind_Click()

On Error GoTo Err_cmdFind_Click
Dim rst As Recordset
Dim strSearchName, CurField, strCriteria
Dim ctl As Control

Screen.PreviousControl.SetFocus
Set ctl = Me.ActiveControl

'Here is the problem code
CurField = ctl.Name.ControlSource

Me.FilterOn = False

strCriteria = "[" & CurField & "] Like '*" & InputBox("Enter the " _
& "first few letters of the name to find") & "*'"


Me.RecordsetClone.FindFirst strCriteria '"[ParentCompanyName] = " &
Me![ParentCompanyName]
Me.Bookmark = Me.RecordsetClone.Bookmark


Exit_cmdFind_Click:
Exit Sub

Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click

End Sub



Thanks John
 
john said:
I have the following event procedure set to do a search on any text box I am
on through a Command Button Click, bur I need to have the "ControlSource"
returned for use in the "strCriteria" but do not know the exact Code to
retrieve it? It is basicaly the Field Name of the TextBox.

Private Sub cmdFind_Click()

On Error GoTo Err_cmdFind_Click
Dim rst As Recordset
Dim strSearchName, CurField, strCriteria
Dim ctl As Control

Screen.PreviousControl.SetFocus
Set ctl = Me.ActiveControl

'Here is the problem code
CurField = ctl.Name.ControlSource

Me.FilterOn = False

strCriteria = "[" & CurField & "] Like '*" & InputBox("Enter the " _
& "first few letters of the name to find") & "*'"


Me.RecordsetClone.FindFirst strCriteria '"[ParentCompanyName] = " &
Me![ParentCompanyName]
Me.Bookmark = Me.RecordsetClone.Bookmark


Exit_cmdFind_Click:
Exit Sub

Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click

End Sub

CurField = ctl.ControlSource
 
Back
Top