langianom
12-08-2015, 03:28 PM
Hello,
This question has been posted I am sure, but the search criteria I am using is not coming up with any threads. Sorry if this is redundant. I have found this question on other sites, but they did not seem to help me. I am wanting a textbox field on a form to autocomplete. In other words, if I were to enter the letter J into this field, an autocompletion of the alphabetically first entry in the table for that field beginning with J is filled in, and the list would get refined based on further letters entered.
I have figured out how to do this with a Combo Box, but not a Text Box. I tried to apply the same configuration I did for the Combo Box for the Textbox, but I cannot figure out how to set the Row Source and Row Source Type for a Textbox. I would just use a Combo Box, but the administrators above me want it to be a Textbox for cosmetic reasons.
I am using Access 2010 Pro and Windows 7 Pro, I also have Office 2013 Pro if need be. I have a form called Computers, I have a table called AllFields, and the AllFields table contains all of the available fields I need for the form. The field I am working with has a name of Username.
For the Combo Box that I created that auto complete is working on, here is what I did. I created the Combo Box on the form, set the Row Source Type to Table/Query and the Row Source to SELECT AllFields.Username FROM AllFields WHERE (((AllFields.Username) Like "*" & [Forms]![Computers]![Username].[TEXT] & "*"));
I then setup an After Update Event Procedure with the following code:
Private Sub Username_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
Username.Requery
End Sub
If the after update code was not added, it was going to make me close the form to save the info in the table in order for the newly added data in the table could auto complete. This works perfectly. My goal is to do this same thing but with a Text Box. I tried doing this exact same thing with another field called Location that is setup as Text Box, but it will not auto complete. Other than it not being a Combo Box, the only thing I can see is different is the inability to set the Row Source Type and Row Source Criteria.
I tried creating a Query with the same Row Source criteria as the username field above, but altering the field name to be Location and it still would not work.
I have not used MS Access in 10 years, but still remember a lot of the basics. I am a VBA extreme novice and everything I have figured out to make the Combo Box work was from You Tube videos and forum searches. This tactic does not seem to be helping me with the Text Box feature. I would also be up for a good way hide the drop down arrow of the Combo Box as a last resort. I have tried the putting a Text Box on top of a Combo Box trick and it just seems like a dirty way of doing it.
Anything advice that can be offered would be much appreciated.
Thanks,
Matt
This question has been posted I am sure, but the search criteria I am using is not coming up with any threads. Sorry if this is redundant. I have found this question on other sites, but they did not seem to help me. I am wanting a textbox field on a form to autocomplete. In other words, if I were to enter the letter J into this field, an autocompletion of the alphabetically first entry in the table for that field beginning with J is filled in, and the list would get refined based on further letters entered.
I have figured out how to do this with a Combo Box, but not a Text Box. I tried to apply the same configuration I did for the Combo Box for the Textbox, but I cannot figure out how to set the Row Source and Row Source Type for a Textbox. I would just use a Combo Box, but the administrators above me want it to be a Textbox for cosmetic reasons.
I am using Access 2010 Pro and Windows 7 Pro, I also have Office 2013 Pro if need be. I have a form called Computers, I have a table called AllFields, and the AllFields table contains all of the available fields I need for the form. The field I am working with has a name of Username.
For the Combo Box that I created that auto complete is working on, here is what I did. I created the Combo Box on the form, set the Row Source Type to Table/Query and the Row Source to SELECT AllFields.Username FROM AllFields WHERE (((AllFields.Username) Like "*" & [Forms]![Computers]![Username].[TEXT] & "*"));
I then setup an After Update Event Procedure with the following code:
Private Sub Username_AfterUpdate()
DoCmd.RunCommand acCmdSaveRecord
Username.Requery
End Sub
If the after update code was not added, it was going to make me close the form to save the info in the table in order for the newly added data in the table could auto complete. This works perfectly. My goal is to do this same thing but with a Text Box. I tried doing this exact same thing with another field called Location that is setup as Text Box, but it will not auto complete. Other than it not being a Combo Box, the only thing I can see is different is the inability to set the Row Source Type and Row Source Criteria.
I tried creating a Query with the same Row Source criteria as the username field above, but altering the field name to be Location and it still would not work.
I have not used MS Access in 10 years, but still remember a lot of the basics. I am a VBA extreme novice and everything I have figured out to make the Combo Box work was from You Tube videos and forum searches. This tactic does not seem to be helping me with the Text Box feature. I would also be up for a good way hide the drop down arrow of the Combo Box as a last resort. I have tried the putting a Text Box on top of a Combo Box trick and it just seems like a dirty way of doing it.
Anything advice that can be offered would be much appreciated.
Thanks,
Matt