Solved Autofill textbox based on previous values from the same field (1 Viewer)

Nagesh

Member
Local time
Today, 12:22
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:22
Joined
Oct 29, 2018
Messages
21,454
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.
 

Nagesh

Member
Local time
Today, 12:22
Joined
May 10, 2020
Messages
31
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 ?
 

Nagesh

Member
Local time
Today, 12:22
Joined
May 10, 2020
Messages
31
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:

theDBguy

I’m here to help
Staff member
Local time
Today, 02:22
Joined
Oct 29, 2018
Messages
21,454

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:22
Joined
May 21, 2018
Messages
8,525
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

  • MajP FAYT V12.accdb
    1 MB · Views: 330

deletedT

Guest
Local time
Today, 10:22
Joined
Feb 2, 2019
Messages
1,218
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:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:22
Joined
May 7, 2009
Messages
19,232
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
 

Nagesh

Member
Local time
Today, 12:22
Joined
May 10, 2020
Messages
31
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
 

Nagesh

Member
Local time
Today, 12:22
Joined
May 10, 2020
Messages
31
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 !!
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:22
Joined
Sep 21, 2011
Messages
14,232
From one of the threads here.?
Really should be in Sample Databases or Code Repository?

Here it is from my download.
 

Attachments

  • MajP FAYT V10 (2).zip
    149.9 KB · Views: 235

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:22
Joined
May 21, 2018
Messages
8,525
@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
 

deletedT

Guest
Local time
Today, 10:22
Joined
Feb 2, 2019
Messages
1,218
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:22
Joined
Sep 21, 2011
Messages
14,232
@MajP Where is V12 please. I could not find it in a search?
 

deletedT

Guest
Local time
Today, 10:22
Joined
Feb 2, 2019
Messages
1,218
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

You've got your good things, and you've got mine.
Local time
Today, 05:22
Joined
May 21, 2018
Messages
8,525
@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

Top Bottom