combobox properties to allow user to type text in it and let it filter by text entered - vb.net

I have a combobox where I'll need to allow user to search by text and be able to select that value from the list. So what I'm currently doing is, on CBO_KeyPress, I open the drop down.
Me.cboNames.DroppedDown = True
I set the property of the cbo...
AutoCompleteMode=SuggestAppend
DropDownStyle = DropDown
AutoCompleteSource=ListItems
Everything works beautifully except for one issue. As it stands, i have items in the drop down where the width is significantly wider than the combobox - I have a function that adjusts the DropDownWith to longest string in the list of items. My concern is that while this helps user search for correct item, it's width is only as wide as the combobox. Is there a way to adjust this?
My only other option is to not use AutoCompleteSource=ListItems and instead simply open the dropDown programmatically on KeyPress or something. In this case, it doesn't do as good of a job of filtering the items. AutoCompleteSource does it beautifully but the width issue does not make it look right.
EDIT : Plutonix - here's what I did. I changed AutoCompleteSource=None. On CboName_KeyPress I open dropdown programmatically. Now I type in text, see image below....
It doesn't find text 100% of the time as you can see. AutoCompleteSource narrows it down and only shows you the items that begin with the same text as typed by user but the width is the issue. It actually looks much better with AutoCompleteSource because if they type in text that's not in the list of items then it shows nothing - and user known it's not in the list.
Users tab into the filed and start typing text. They don't open it. That's why they want this to be updated like that. I want them to see the items as they type in.

Related

How to find out which field a text box is linked to on a form? (Opposite direction of the ControlSource Property)

I have a form with multiple text boxes and want to select the one that is linked to a specific field in my dataset.
What I'm trying to do is basically the opposite direction of the ControlSource property... I know the field and want to find the associated text box.
E.g.: My dataset consists of the fields : Height, hair colour, weight, shoe size.
I have a form equipped with text boxes (for data entry) for each and every one of those fields.
I now want to select the text box linked to the field "weight"....
I could cycle through the controls on the form without a question, but is there a property of the text box telling me which field it's currently linked to?
I think I'm just too dumb to google it, but I just can't seem to find anything of the sort...
Thanks for your help in advance!
I could cycle through the controls on the form without a question, but
is there a property of the text box telling me which field it's
currently linked to?
Yes, that is - as you mention - property ControlSource …
So, loop the controls collection of the form (filter on control type TextBox) and find that (or those as it could be) bound to your field.

Assign data to an item in a list?

I've set up a list that shows all available fonts. The issue I am having is assigning the actual font "data" to the list item itself so that, when clicked, it will apply that font to the textbox.
How would I go about doing this?
(I'm entirely new to this)
You don't need to, in your case. But if I interpret your question correctly..
What you can do is something like this:
myTextBox.Font = New Font(myListBox.SelectedItem, myTextBox.Font.Size)
This way, you'll be able to assign the font to the textbox based on your listbox's selected item, provided the listbox item IS the name of the font.

Adding multiple textboxes to a form in ms-access?

I would like to have a line on an Access user-form. Call it Item #1. I would like Item #1 to be a text box where the user can enter any type of information. So for example, say the user entered "Tutoring" and then next to this was an additional Textbox that allowed the user to enter the hours spent tutoring and the date in which the hours were logged.
What I would like is to have a button to allow the user to add a second line (or set of textboxes) when needed, or a third line, etc. Is this something that can be set up on the Access form? Does this need to be coded in VBA? Just looking for some tips to provide me some direction on the best approach.
"If the data should not be stored in a table, it' a bit more complicated. "
You would have to make the text boxes not visible when the form loads, and then make each text box visible on the After Update event of the previous box.

How can i set an Horizontal scroll or multiline text on a Combobox ? ( Vb.net)

I ' ve a combobox with too long multiple Items . There is any method to set a horizontal scroll in combobox or set a multiline properties for each item ?
Hi Mattia,
There are a couple of methods that are usable as well as effective for this problem you are having, here is the concept that I've created that you may implement in your project;
Original text: C:\path1\path2\path3\path4\file.exe
Combo Box text: C:\path1\p...file.txt
To do this you will 1st have to specify how many characters you want to shown in the start of the text (1st 5 or so) then you must specify how much you would like to leave off at the end (last 6 or so).
I realize this causes a problem, "I wont be able to see the full path!", however adding a 2nd form or a msgbox to display the full text which should initiate the 1st 2-4 secs of display time, this should not be a challenge nor a problem and will make you look like a Pro!
I hope this helped you with your problem or motivated you to go over and beyond!

Gray out a form row's (detail's) button conditionally with VBA code

I have a standard form in MS-Access which lists a bunch of orders, and each row contains order no, customer, etc fields + a button to view notes and attached document files.
On request from our customer we should gray out the button btnAnm (or check or uncheck a checkbox) depending on a calculation from two queries to two other tables (a SELECT COUNT WHERE and a check if a text field is empty).
I've tried btnAnm_BeforeUpdate(...) and btnAnm_BeforeRender(...) and put breakpoints in the subs, but none of them trigger. The same if I use the control Ordernr instead of btnAnm.
I'd like a function in the Detail VBA code to be triggered for each "Me." (row) so to speak, and set the row's control's properties in that sub.
What do I do? I've looked at the help file and searched here.
*Edit: So I want to do something that "isn't made to work that way"? Ie. events are not triggered in Details.
As an alternative, could I base the value of a checkbox on each line on a query based on the 'Ordernr' field of the current row and the result of a SELECT COUNT from another table and empty field check?
Do I do this in the query the list is based on, or can I bind the extra checkbox field to a query?
A description of how to do this (combine a COUNT and a WHERE "not empty" to yes/no checkbox value) would be perfectly acceptable, I think! :)*
You cannot do much with an unbound control in a continuous form, anything you do will only apply to the current record. You can use a bound control with a click event so that it acts like a button.
Presumably the related documents have a reference to the order number that appears on your form, which means that you can create a control, let us call it CountOrders, with a ControlSource like so:
=DCount("OrderID","QueryName","OrderID=" & [OrderID])
The control can be hidden, or you can set it up to return true or False for use with a textbox, you can also use it for Conditional Formatting, but sadly, not for command buttons.
Expression Is [CountOrders]>0
You can also hide the contents and add a click event so that is acts in place of the command button. Conditional Formatting will allow you to enable or disable a textbox.
As I understand your question, you have a continuous form with as command button that appears on each row - and you'd like to enable/disable the button conditionally depending on the contents of the row.
Unfortunately you can't do that. It seems that you can't reference the individual command buttons separately.
Having wanted to do something similar in the past I came up with two alternate ways of setting up my interface.
Put a trap into the onClick code for the Button. Which is icky, because it is counter intuitive to the user. But it gets you that functionality now.
Move the command button (and editable fields) up into the form header, and make the rows read only. Your users then interact with the record only in the header, and select the record they want work with in the list below. As I recall this is known a Master-Detail interface.