Solved Autofill textbox based on previous values from the same field

Nagesh

Member
Local time
Today, 11:25
Joined
May 10, 2020
Messages
31
I have a textbox for 'Project name' in the form.
Is there an option to autofill this field, based on previous values from the same field?

As there are new projects getting added, this 'Project name' textbox cannot be converted to combobox and obtain values through drop down.
At the same time, I want the user to key in correct project name as it was keyed in earlier.
 
Hi. If you want auto-data-validation, then using a Combobox would be the recommended approach. If you don't want to user to go through a very long list, you can implement a "search-as-you-type" feature. Also, keep in mind, the user is free to type into a combobox - they don't have to click on the dropdown arrow to select an entry.
 
Hi. If you want auto-data-validation, then using a Combobox would be the recommended approach. If you don't want to user to go through a very long list, you can implement a "search-as-you-type" feature. Also, keep in mind, the user is free to type into a combobox - they don't have to click on the dropdown arrow to select an entry.
It's the DBguy again...
Thanks for your swift response.
Pardon my ignorance, but where can I find "search-as-you-type" feature ?
 
Hi. If you want auto-data-validation, then using a Combobox would be the recommended approach. If you don't want to user to go through a very long list, you can implement a "search-as-you-type" feature. Also, keep in mind, the user is free to type into a combobox - they don't have to click on the dropdown arrow to select an entry.

I replaced the textbox with the combobox, but there's a huge list of project names.
However, the great thing is the autofill option works well as required.
Is this the only way?

Neverthelss, can we have the same thing working from just the textbox?
 
Last edited:
Here are multiple search as you type options. Combobox, listbox, or form. All of them require a line or two of code to use. Read the instructions.
As there are new projects getting added, this 'Project name' textbox cannot be converted to combobox and obtain values through drop down.
At the same time, I want the user to key in correct project name as it was keyed in earlier
Not sure what you are saying here, but a combo box can allow the user to enter new names or choose from the list.
 

Attachments

Here are multiple search as you type options. Combobox, listbox, or form. All of them require a line or two of code to use. Read the instructions.

Not sure what you are saying here, but a combo box can allow the user to enter new names or choose from the list.

@MajP you may want to correct the following error in FindAsYouTypeCombo class. You're missing a closing quotation mark.

2020-05-11_14-09-21.jpg
 
Last edited:
add code to the Form's BeforeInsert event:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    With Me.RecordsetClone
        If Not (.BOF And .EOF) Then
            .MoveLast
            Me.txtProjectNumber.DefaultValue = Chr(34) & ![ProjectNumberField] & Chr(34)
        End If
    End With

End Sub
 
Here are multiple search as you type options. Combobox, listbox, or form. All of them require a line or two of code to use. Read the instructions.

Not sure what you are saying here, but a combo box can allow the user to enter new names or choose from the list.

Exactly as required (and more)
Thanks very much MajP
 
add code to the Form's BeforeInsert event:
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
    With Me.RecordsetClone
        If Not (.BOF And .EOF) Then
            .MoveLast
            Me.txtProjectNumber.DefaultValue = Chr(34) & ![ProjectNumberField] & Chr(34)
        End If
    End With

End Sub
Thanks arnelgp
Your suggestion was much simpler and working well !!
 
From one of the threads here.?
Really should be in Sample Databases or Code Repository?

Here it is from my download.
 

Attachments

@Tera,
Not sure what the issue is, but it must be an issue in the downloading from the site or conversion to non US Access. The problem you talk about does not exist in the version 12. I downloaded v12 and there is no issue with closing quotes.
quotes.png
 
I tried it once again. Still the same error. Maybe because I don't have those special characters installed. No big deal. I can correct it myself.

Thanks.
 
@MajP Where is V12 please. I could not find it in a search?
 
Tera,
See what happens to my V10 version?
The same. As you can guess I don't have French, German and Spanish languages installed. So those characters doesn't exist in my character set.
 
@MajP Where is V12 please. I could not find it in a search?
That is the one I posted in this thread #6. It has the update to search a multi column combobox, and search all fields.
 

Users who are viewing this thread

Back
Top Bottom