Find Command Button Defaults

G

Glenn E. White

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
 
D

Don Wilson

There is no way to use a look in procedure that i know of.

But you can accomplish what you want by enabling the field
in the code window by adding 2 lines of code.

Add this line to your command button.
Place it at the top of your procedure so it fires before
you open the find dialog.

FieldName.Enabled = True


Add This line of code to your "On Got Focus" event
procedure of the form you are working in.

FieldName.Enabled = False

P.S.
You donot have to de-enable a field if you have it locked.
Locking a field denies edit but allows selection.
 
A

Allen Browne

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?
 

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

Top