Making a text box a find field.

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

Guest

Is there anyway to make a text box a find field? The way my database is set
up is that I have 2 different forms, one form (ID) is only used to add an ID
number, the other form (Distribution List) is used to add personel
information to the ID number. Is there a way I can code it so when I enter
an ID number to the ID form, if that record already exists it will
automatically take me to that record in the Distribution List form, and if
that record does not exist it will take me to a new record with that ID
number? Is there any other way I might be able to accomplish this?
 
Roger said:
Is there anyway to make a text box a find field? The way my database is set
up is that I have 2 different forms, one form (ID) is only used to add an ID
number, the other form (Distribution List) is used to add personel
information to the ID number. Is there a way I can code it so when I enter
an ID number to the ID form, if that record already exists it will
automatically take me to that record in the Distribution List form, and if
that record does not exist it will take me to a new record with that ID
number? Is there any other way I might be able to accomplish this?

You need two controls for [ID]. Put one in the form header named IDFilter
and make it unbound (no ControlSource). Put the other one in the detail
section, bind it to the [ID] field and make it hidden.

In the AfterUpdate event of IDFilter have code...

Me.ID.DefaultValue = Chr(34) & Me.IDFilter & Chr(34)
Me.Filter = "[ID] = " & Me.IDFilter
Me.FilterOn = True

The way this works is the user enters the desired ID in the IDFilter
control and presses <Tab> or <Enter>. A filter is applied to show the
record having an ID value that matches their entry. If there is one found
it will be displayed. If there is not the form will display the blank (new
record) position and since the default value property has been set to the
searched for value any new record entered will have that value.
 
Rick, I got the code to work but not how I thought it would. When I search
for an ID number, thats all it brings up (It brings up a blank record with
that ID number on it, there are like 10 other fields, and I want all the
information from the record to show when I search). Is there a way to pull
all the information by entering the ID number?

Rick Brandt said:
Roger said:
Is there anyway to make a text box a find field? The way my database is set
up is that I have 2 different forms, one form (ID) is only used to add an ID
number, the other form (Distribution List) is used to add personel
information to the ID number. Is there a way I can code it so when I enter
an ID number to the ID form, if that record already exists it will
automatically take me to that record in the Distribution List form, and if
that record does not exist it will take me to a new record with that ID
number? Is there any other way I might be able to accomplish this?

You need two controls for [ID]. Put one in the form header named IDFilter
and make it unbound (no ControlSource). Put the other one in the detail
section, bind it to the [ID] field and make it hidden.

In the AfterUpdate event of IDFilter have code...

Me.ID.DefaultValue = Chr(34) & Me.IDFilter & Chr(34)
Me.Filter = "[ID] = " & Me.IDFilter
Me.FilterOn = True

The way this works is the user enters the desired ID in the IDFilter
control and presses <Tab> or <Enter>. A filter is applied to show the
record having an ID value that matches their entry. If there is one found
it will be displayed. If there is not the form will display the blank (new
record) position and since the default value property has been set to the
searched for value any new record entered will have that value.
 
Back
Top