Error: Control can’t be edited; it’s bound to the expression “Company ID”

Don't use the After_Update event of the Find textbox. Create a button that when clicked will open the form. All that you need to know is in the db.

I was using the After_Update because I have a habit of hitting Enter after I enter the FindWhat data.

What's the reason why I should not use the After_Update event?
 
If you were typing in the box and you mistakenly tabbed out then the AFTER_UPDATE event will fire. It's up to you how you want things to happen anyway.
 
If you were typing in the box and you mistakenly tabbed out then the AFTER_UPDATE event will fire. It's up to you how you want things to happen anyway.
Okay, that makes sense.
 
vbaInet,

I want the DefaultValue to equal 2 for Company Name. I tried revising to:


Private Sub List6_Click()
Me.List6.DefaultValue = 2
lblFindWhat.Caption = Nz(List6.Column(2), "i'm blank")
txtFindWhat.Width = Val(Nz(List6.Column(4), 1800))
txtFindWhat.Left = Val(Nz(List6.Column(5), 0))​
End Sub​

but it's not working. I removed the Form_Load event but it's still not working. Suggestions, please!
 
The DefaultValue property is only effective for BOUND controls.

If you want the listbox to select the first item when the form is opened, then use the LOAD event and select the first item (bearing in mind that a listbox is zero-based).

listbox1.Selected(0) = True

Good luck with the rest!
 
The DefaultValue property is only effective for BOUND controls.

If you want the listbox to select the first item when the form is opened, then use the LOAD event and select the first item (bearing in mind that a listbox is zero-based).

listbox1.Selected(0) = True

Good luck with the rest!

Perfect! Thank you!


One last question. In your code you have: "lstFindFields.Value = vbNullString" Reasoning? I'm trying to understand each statement; therefore, I am asking what this statement will accomplish.
 
It's a way of deselecting the highlighted value in the listbox and it also resets the value of the listbox as well.

Remember there's the help files as well. It's quite useful and in some cases you will find examples. Press F1 in the vba editor and it will open up HELP for vba.
 
It's a way of deselecting the highlighted value in the listbox and it also resets the value of the listbox as well.

Remember there's the help files as well. It's quite useful and in some cases you will find examples. Press F1 in the vba editor and it will open up HELP for vba.

Thank you very much!!!
 
In regard to the AfterUpdate thing, I dissent from the advice you've been given. I like having ENTER execute the search. That's the way SUBMIT works in an HTML form on a web page, and I think consistency with the way the web works is a good thing.

I also will often add a FIND command button with no events for the uninformed who don't know to hit ENTER. Clicking the FIND button does nothing, other than taking the focus from the textbox and forcing the AfterUpdate event.
 
Great advice David.

With regards the After_Update event, there are cases where having the code in that event will be wise, I do that too. But in the OP's case it's opening a form. You wouldn't want it to fire if everytime you make a mistake the form opens.
 
In regard to the AfterUpdate thing, I dissent from the advice you've been given. I like having ENTER execute the search. That's the way SUBMIT works in an HTML form on a web page, and I think consistency with the way the web works is a good thing.

I also will often add a FIND command button with no events for the uninformed who don't know to hit ENTER. Clicking the FIND button does nothing, other than taking the focus from the textbox and forcing the AfterUpdate event.
Or a close alternate method is to set the command button's DEFAULT property to YES and then put the code to do the search there. If the user clicks on the button it will happen, if the user hits enter, it will click the command button.
 

Users who are viewing this thread

Back
Top Bottom