ctl.Name

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
 
B

Baz

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top