Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoFill Textboxes

Status
Not open for further replies.

curlydog

Technical User
Aug 18, 2004
14
0
0
GB
I have a form that receives information that may well have been input previously. I'm trying to make the inputters job a little easier.

The first textbox takes information that is likely to have been previously input. Is it possible to have the textbox autofill depending on the first few characters that the inputter types.

I know that combo do something similar, but can I get this effect with a text box. If I haven't made myself too clear this is the kind of thing I'm looking for. The inputter types in the letter "B" and the first word starting with "B" autofills the box, the inputter then types the letter "R" and the first word begining with "BR" fills the box. This continues until the the correct word appears at which point the user tabs to the next field and the word in the previous textbox is accepted as the entry.

Conversely if the word that the inputter wants does not appear in the textbox, they continue to type the whole word.

Also it is likely that my inputter will be entering numerous consecutive entries concerning the same person. People are chosen via a combo drop down list. Again to makelife easier I'd like to make the value of the drop down list the previously selected value. At the moment the inputter clicks a button to save the record they have just input. The record is saved and they are then presented with a blank form. I'd like the form to remember the previous choice made from the drop down list. In this way the when the inputter clicks the button to save a record all of the forms fields are blank apart from the person drop down list whos default value is the name of the previous entry.

Thank for any help
Jason
 
well, the 2nd bit is easy...

just set a global variable in a module somewhere, and everytime you save a record, keep the values you want kept in the global variable...
and just fill in the values accordingly in form onLoad()

As for the first bit, well, I don't think there's anything like that built in for textBoxes, so you'd either have to write your own code, or just use a comboBox...
 
For the first bit I did change to a combobox, but it's created a strange problem of it's own.

When I press the "tab" button to get out of the combo box, I get an error saying "You cannot add or change a record because a related record is required in table 'tblOTSource' ".

It's strange as it appears to be a problem with referential integrity in the combobox. the combobox gets it's data from a column that does not refer to anything.

The only thing that refers to the table mentioned is a textbox which is further down the form.

It appears that the form is trying to save the record when I tab out of the combobox, but there are no event procedures assigned to it. Strangely enough this problem does not occur when I click in another textbox, only when I'm in the combobox and click tab.

Why would it do this?
Jason
 
that's cos you've bound your combobox to a column that is required...

if unbound the combobox, then you'll be ok, but remember, when saving, you'll have to manually save that value to the record...
 
Although the combobox is bound to a column, the column that it is bound to is not required.

The column from which the data is retreived has the properties (in table design view)

Required=No
Allow Zero Length=Yes

Unless I'm missing another property somewhere, I can't see that a value from the combobox is, or why it should be required.

Hence my original theory that it is a referential integrity problem relating to a textbox further down the form and the fact that the form is trying to save the record as I tab out of the combobox.
 

I sounds as the field you're talking about is has been set as a foreign key.

Have you checked the relationship for the table.
 
There is a foreign key relationship between the two tables, but not concerning the column from which the combobox is filled. The column from which the combobox is filled does not reference anything.

The foreign key relationship relates to a column to which the textbox I mention is bound.

When I tab out of the combobox, I haven't yet got to the textbox which is bound to the foreign key column, so it is still empty.

It appears that the form is trying to save the record when I tab out of the combobox and this is where the problem with referential integrity is caused.

My problem is trying to figure out why the form is trying to save the form when I tab out of the combobox.

Jason
 
well, you've presumably bound your form to the table, so whenever you try to update anything, the form will try to save the changes...
 
Yes the form is bound to the table. But if the form tries to save changes when I update anything why does this problem only occur when I tab out of the combobox?

I don't have a problem if
a). I type my value into the combobox and then click in the next box with the mouse. Or
b). I select the value from combobox with the mouse and then click into the next box.

As I say, the problem only occurs when I use the tab button to get out of the combobox.

Jason
 
Jason

This is a bit of a guess but if the cycle property of the form is set to "All Records" and the combo box is the last control on the form then when you tab to the next control the form will be trying to go to a new record.

Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top