Find function on form

Mansoor Ahmad

Registered User.
Local time
Today, 12:19
Joined
Jan 20, 2003
Messages
140
Dear All

I have a form in my database based on a query. To search for particular records on that form I have put a combo box with following event procedure

Private Sub Combo245_AfterUpdate()
Dim vName As String

vName = Combo245
If Not vName = Empty Then
PART_NO.SetFocus
DoCmd.FindRecord vName, acEntire, False, , False, , True
End If
End Sub

The problem that has come up is when we type in the Part No we are searching for in combo box and press enter, cursor goes to Part No field on form and even if the typed Part No is not in list, cursor still goes to that field and sometimes users can modify the actual data not relevant to that record. How can I make it work that if the part no is not in the list and we press enter, it would give some message that this part in not in the list.

Another related problem is that can we change the focus of cursor from Part No field to any other field on the same form. I have tried to set its property to Not Enabled but then find function of combo box does not work. I have also tried to remove tab stop from Part No field but still focus of cursor from combo box goes to this field?

Thanks
 
Mansoor Ahmad said:
The problem that has come up is when we type in the Part No we are searching for in combo box and press enter, cursor goes to Part No field on form and even if the typed Part No is not in list, cursor still goes to that field and sometimes users can modify the actual data not relevant to that record. How can I make it work that if the part no is not in the list and we press enter, it would give some message that this part in not in the list.

Set the combobox's LimitToList property to Yes.

You can then customise the error message using the NotInList event.
 
That was really quick. Thank you.

I will try it now.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom