User form text box question

jcaptchaos2

Well-known Member
Joined
Sep 24, 2002
Messages
1,032
Office Version
  1. 365
Platform
  1. Windows
Is there a way to prevent someone from entering something into a text box on a user form that is not in a list? If I name the list can I enter that name some where in the properties to prevent it from being entered?

Thanks
 
Sorry but without seeing your actual workbook I don't know what else to suggest, other than double-checking that your named range is looking at the right data and your combobox is pointing to the correct named range. If you want to send me your file to take a look then send me a private message and I'll give you my email address.

DK
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi mate

I had a look at the file you sent me and have figured out what the problem is.

It seems as though in order to use the MatchFound property the MatchEntry must be set to something other than fmMatchEntryNone. In your case, the MatchEntry property will need to be set to fmMatchEntryComplete. I don't know of an easy way around this without resorting to some additional VBA code. Your original BeforeUpdate procedure should also be changed to this:

Code:
Private Sub txtemplon_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)

If Len(Me.txtemplon.Text) = 0 Then Exit Sub

If Me.txtemplon.MatchFound = False Then
    MsgBox "Incorrect Item Number.", vbInformation, "Invalid Entry"
    Cancel = True
End If
End Sub

The first line is needed because some of your code sets the txtemplon control's value to a blank string - without the additional line of code the error message would be displayed.

HTH
DK
 
Upvote 0

Forum statistics

Threads
1,216,135
Messages
6,129,075
Members
449,485
Latest member
greggy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top