Find Command Button Defaults

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help. I have a command button on a form that brings up the Find dialog box. The field I want the user to search on is an Autonumber field. The control on the form that displays the data in that field is set to Enabled = No and Locked = No.

Is there a way to set the default "Look In:" value on the Find dialog box to the field I mentioned above through VBA code?

Any and all help will be greatly appreciated.

Sincerely,
Glenn E. White
 
Glenn, you would need to set focus to the field first.
You could do that if you set its Enabled to Yes, Locked to Yes, and TabStop
to No.

You may find it better to provide an unbound text box on the form (in the
Form Header section?) where the user can just type a number to find. This
example assumes the box is named "txtGoto", and the autonumber is called
"ID".

Private Sub txtGoto_AfterUpdate
If Not IsNull(Me.txtGoto) then
If Me.Dirty Then 'Save before move.
Me.Dirty = False
End If
With Me.RecordsetClone
.FindFirst "ID = " & Me.txtGoto
If .NoMatch Then
MsgBox "not found"
Else
Me.Bookmark = .Bookmark
End If
End With
Me.txtGoto = Null
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Glenn E. White said:
Please help. I have a command button on a form that brings up the Find
dialog box. The field I want the user to search on is an Autonumber field.
The control on the form that displays the data in that field is set to
Enabled = No and Locked = No.
Is there a way to set the default "Look In:" value on the Find dialog box
to the field I mentioned above through VBA code?
 
Back
Top