Prevent User From Entering Values Into Combo Box
hey all...i designed this code a couple of months back while doing my IT school project, in order to prevent the user from entering any values into the combo box other than the values in the list. I have taken much from VBForums..so i think its the smallest thing I can do
Private Sub combo1_Change()'The following code is to prohibit the user from entering anything that is not an item in the list of the combo boxDim num As Longnum = combo1.ListCount - 1 'giving the variable [num] the value of the combo box;s list count (number of items in the list) minus 1Dim txt As Stringtxt = combo1.Text 'giving the variable [txt] the text in the combo boxFor i = 0 To num 'looping from 0 to num combo1.ListIndex = i 'assigning the list index to the value of [i] If combo1.Text = txt Then 'check if the text entered matches the item in the list combo1.Text = txt Exit Sub Else combo1.ListIndex = -1 'assigning the list index a value of [-1] in order to 'make the text in the combo box as "" End IfNext iBeepEnd Sub
Hope someone finds it useful
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Prevent User From Typing Values Into Combo Box
ITtoolbox Portal for Visual Basic - http://visualbasic.ittoolbox.com/
How to prevent user from keying in values into combo box.
Promen Technologies Limited
Prevent User From Entering Pipes Into Textbox
I have a textbox that I don't want to allow Pipes to be entered in.
I am using the keyup event and I know how to figure out when the user hits the Pipe key. I am then taking the text in the textbox and taking away one character. this is ok but the cursor now is at the beggining of the textbox instead of at the end of the last character where it should be.
Is there a better way to do this?
User Entering Values Into A List View
What I need to have is some kind of control that will list a bunch of products and have the ability to have the "amount" of that product entered in beside it.
But because the list of products is dynamic, (based on a combobox selection), I can't just hard code them into the form. Also, the user will be entering in many volumes at once, so doing a drop down box for the products will just waste time.
I was wondering if it was possible to enter values into a second column of a list view. Is this possible?
I've seen some solutions using c# using the .editable property but I dont see that property anywhere for the listview I'm using....
Entering Only Numeric Values
How could I allow the user to be able to only enter numbers in a text field?
I was thinking of using a KeyUp event that checks for a numeric value
IsNumeric(txtTest.text) after every time they type something in but I imagine there is a more efficient way to do this. Any ideas?
Entering Values Into List Boxes Of Ie
how can i select values from a list box ...........i am using the following code to enter value into text box............how cud it be modified to suit list box?
Dim IExp As SHDocVw.InternetExplorer
Dim hDoc As MSHTML.HTMLDocument
Dim hCol As MSHTML.IHTMLElementCollection
Dim hInp As MSHTML.HTMLInputElement
Dim hPoint As MSHTML.tagPOINT
Set IExp = New SHDocVw.InternetExplorer
Set hDoc = IExp.document
Set hCol = hDoc.getElementsByTagName("input")
For Each hInp In hCol
Set IExp = New SHDocVw.InternetExplorer
IExp.Visible = True
IExp.navigate "some webpage"
If hInp.Name = "FILE" Then
hInp.Value = "unmph*vcaesn*"
thanks & regards
Entering Text Into Combo Box
I havnt used combo boxes in dropdown combo style before, so need a bit of help with this
I am making a control panel for db values that my app uses
there are 3 cascading combo boxes in a control array controlled by a select statement.
this is how I populate each successive combo based on the last ones click event data. so showing the final data for a record that has all the selected properties
that means that currently if the user types in new properties it has no effect at all
if the user clicks a command button they should then be able to enter text into the combo box OR select a current value that they may change a successive combo (IE building up a new record)
what is the best way of pulling in this typed in text or selected vaue?
the click event wont fire if the user just types then moves focus and the click event wont suit for if the user selects an option that is already there
Ta in advance, much appreciated
Entering Dates In Combo Boxes (2) ??
First of all thanks to "bsmith" for getting me started. I have now got the dates reading into the combo box, but after each date in the list appear two characters that look like two bold |'s, (ie) 01 Jan II etc...
Is there any way I can get rid of these, to be able to just show the dates (ie) 01 Jan
Below is the code I am using and also my original problem:
Hope someone can help...
Private Function PopulateDates(strForYear As String)
Dim dtStartDate As Date
Dim dtCurrentDate As Date
dtStartDate = CDate("01/01/" & strForYear)
dtCurrentDate = dtStartDate
Do While strForYear = Format(dtCurrentDate, "yyyy")
Combo1.AddItem strForYear2 & Format(dtCurrentDate, "dd mmm ") & vbCrLf
dtCurrentDate = dtCurrentDate + 1
Private Sub Command1_Click()
Is there any possible way that you can use an array or something like it to fill a list box with all the possible dates of the year, with just the date and month and not the year????
(ie) having it automatically display 1st January til 31st December...without the year being shown...????
Hope someone can help...
Entering A Series Of Numeric Values (comma Seperated) Into A Text Box
I'm an old newb, I used VB6 years ago, but now I'm back to do some additional projects and I'm quite rusty.
I'm using the following:
one text box called txtval
a command button called cmdadd
and another textbox called txtmeasures
I enter a numeric value in txtval, click my command button cmdadd and add the entered value to txt measures.
This I can do on my own. However I want to be able to loop this procedure to enter more than one value, so that the values are seperated by commas.
I'm stuck, I know I'm missing one more piece to this code but cant figure it out, see my code below:
I think I need some sort of variable to hold the subsequent values I enter.
Dim x As Integer
Dim i As Integer
For x = 0 To i
txtmeasures = txtval & ", "
txtval = ""
Any help would be much appreciated!
Entering Items In A Combo Box In Word 2000
I'm trying to do my first combo box with multiple items, one of which the user will choose. How do you put the text in the box????? I went to the properties box down to Text and typed the first item, but I don't know how to add a second, third and fourth. Is this the place to do that? Or do I do that in my If statement?
User Finishing Code Help (them Entering Stats)
ok im making an auto adopter and i need to have a command where the user can imput the strength and defence and level and then the program to look for it. sending hte key f5 (i know how to do that) so umm my only problem is the stats imput
Preventing User From Entering Data In Textbox
i have a textbox on my form, i don't want the user to input anything in there for now,the enable false property of the text blurs the text too much, is there another way of preventing this,i can't use labels because later on in the program i want the user to enter text in the same text box.
Msflexgrid: User Entering Text To Cell
with the msflexgrid control
how can I allow the user to enter/edit text in a cell? (like as in a textbox)
Does it have this ablility, or do I have to fudge it by putting a textbox over the cell with the focus,etc..
Restricting A User From Entering 2 Decimal Points In A Value
In my application I have a text box which accepts data and processes it accordingly. This text box is used to accept only numbers and so I have validated the same using the Keypress Event. I have disables all alphabets and special characters. The only characters that can be entered into this text box is numbers 0 to 9 (vbKey 0 to vbKey 9) and Backspace vbKey 46. However decimal points are allowed. But the problem is that a user can enter more than one decimal point. for eg: 1.2.1 I want to restrict the user from doing that.
I have tried entering the following piece of code.
In the Keypress Event:
Case vbKey Decimal
Keyascii = 0
But this doesn't help. I want the user to enter a value with a maximum of one decimal point.
Anyway to do the same.
How To Prevent From Saving Duplicate Values...
I am using MSAccess database and tbl_NoDuplicates has 4 fields (Name, City, Telephone, Fax). Now when I enter the duplicate (Existing values) record and press SAVE button it accepts. I want to write code which should check in all the fields of the table and make sure that there is no dulicates values then only it should SAVE the record otherwise give messages that it cannot be saved. Using textboxes for the input.
Thanks in advance.
How To Prevent Typing In Combo Box?
I have a bunch of combo boxes I need to prevent typing in. They're pulling the data from tables, and the contents are managed in another form to prevent people from entering a bunch of junk. I'd like to prevent the users from typing in the combo boxes, but I don't want to lock them, as the users need to be able to change the values. Any ideas?
Prevent Typing A Value In Combo Box
how do i prevent people from typing in stuff into my combo box? i want them to only be able to select the things that are there....i've tried 'locked' but that just doesn't let you choose anything.....any other ideas? thanks.
Prevent Duplicates In Combo
Ok, I am loading data to a form from an AccessDB via ADODB. While I am only displaying the first record, I want to populate a couple of Combo boxs also.
rsTable.Open "SELECT * FROM Table ORDER BY ID", CN,adOpenForwardOnly, adLockReadOnly
txtID = rsTable!ID
txtText1 = rsTable!Text1
Do While Not rsTable.EOF
cboFName = rsTable!FName
cboSurname = rsTable!Surname
However this is causing duplicate entries in my Combo boxes, if there is more than one "Ann" in the database. Will have have to open a separate DISTINCT recordset to populate the combo boxes, or can I just check if "Ann" is already in the Combo?
Thanks in advance
Prevent Typing In Combo Box
I have a project and I need to have the combo boxes as style 0 dropdown combo. I am using the click event to detect changes when the user selects a new item from the dropdown. However I want to stop the user from being able to type in the combo box, but I want to allow them to use the delete key to blank the contents. If I use the enabled property and set it to false then you can't select from the dropdown. any ideas???
How To Prevent Combo Box Event
I have two combo boxes. Bases up on the first combo box selected
item, second combo box items should be populated. And i have written
some code in the first combo box clicl event. when i am setting the
first combo box list index = -1 or clearing then corrosponding click
event also firing. how to prevent this?
thanks & regards,
How Do I Prevent User From Saving The Xls?
I need some help with preventing the user from saving the xls file and was hoping someone out there could tell me what I'm doing wrong.
What I have is an excell file that contains a single spreadsheet (called Main) which acts as my application menu. The user makes selections and provides input via this "Main" sheet and my vba code processes the input and then displays the output in a second sheet that I create on the fly.
I would like to prevent the user from saving the workbook so when it is reopened, only the one sheet (Main) is there. BTW...I also want to surpress any messages that may normally be displayed as well.
I've added the 2 lines below in the following subroutines but they don't seem to work as I understood they were suppose to.
Application.DisplayAlerts = False 'surpresses messages?
ThisWorkbook.Saved = True 'fools excel into thinking no save is needed?
Edit by Moderator:
Please post Excel questions, in the Excel forum.
Prevent User From Closing App
I want to prevent the user from closing my application, even if they use EndTask or EndProcess.
I wrote a program using VB, run it every 10 minutes and I want users not to disturb the task and not to abort it themselves.
I startup the program at every startup in a hidden way so that it is shown only in the taskmanager not in the tastbar so as to not to disturb them. The program has a timer in it which executes every 10 mins. Is there any way for it ? Please help me out.
Prevent Prompting To User
when i open an excel file from vb....save file as...del some sheets.it will prompt the user to confirm delete..how do i stop this prompting?
Prevent User From Closing With [x]
I need to, if and when certain conditions are met, not allow the user to close the program via the [x] in the upper right corner.
I'm logging some time with a start/stop (timecard style), and the program needs to stay active during this so the user can work work work, then hit stop. I have working code in my cmdExit button, but when I go to the Form_Unload(Cancel as Integer) sub, and insert the same code, it will display my MsgBox but won't exit the sub, and thus ends the program.
So how do I go about this?
Prevent User Pressing Alt+tab
Im trying to stop a user from pressing ALT+TAB
They are using this to gain an advantage a confuse a peice of monitoring software.
Is there a way to stop it even if focus is not in the applications window.
This code i tried with no success
Private Declare Function SystemParametersInfo Lib "user32" _
Alias "SystemParametersInfoA" (ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long) As Long
Private Const SPI_SCREENSAVERRUNNING = 97
Private Sub Command1_Click()
Dim ret As Integer
Dim pOld As Boolean
ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
Private Sub Form_Load()
Command1.Caption = "Disabled"
Command2.Caption = "Enabled"
Private Sub Command2_Click()
Dim ret As Integer
Dim pOld As Boolean
ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
Private Sub Form_Unload(Cancel As Integer)
' re-enable Ctrl+Alt+Del and Alt+Tab before the program terminates
this also blocks ctrl+alt+del which was an added advanatge
Edited by - Big Al Inc on 3/19/2006 5:52:37 PM
How Can I Prevent Duplicate Entry In A Combo Box?
I was wondering if someone could tell me how to prevent duplicate entries in a combo box. I used to know how to do this, but it's been a couple years since I messed with vb6, so I forget.
For instance, I have a form with a combo box that the end user can use to add names to. My problem is that if the end user enters a name that is already there, it will put it in again. I want to prevent that and display a message saying that it is already there. Here is my code for the Command button to enter entry:
Private Sub Command1_Click()cboPlayers.AddItem cboPlayers.TextOpen "c:Documents and settingsDavedesktopcomboPlayers.txt" For Append As #1 'opens Players.txtOpen "c:documents and settingsdavedesktopcombo" & cboPlayers.Text & ".txt" For Output As #2 'opens or creates "the name of the player".txtPrint #1, cboPlayers.Text 'Writes the contents of the Combo box's text field to Players.text Since previous line was Open For Append, it will add to the end of test.txtClose 'Closes all open filescboPlayers.Text = ""End Sub
**RESOLVED** Prevent Tabbing Out Of Combo Box
I have a form with a number of controls on it. I want to disallow users from being able to tab out of a specific combo box but--and here is the kicker--I still want them to be able to tab throughout the other controls on the form.
Sounds easy but I am not finding it to be. Advance Thanx...
Prevent Context Menu In Combo Box
I am using a drop down combo box in a dialog. I want to prevent the context menu on right clicking combo box. Could anyone help me in this regard? All suggestions are highly appreciated.
Thanks in advance,
Prevent User From Adding More Than 3 Records
I need to restrict the user from entering more than 3 records into a datasheet and I have no idea how to do this.
Can someone give me some ideas? I'm sure this came up before but i couldn't find anything through search.
Prevent User From Erasing File
I have many users that are not savvy and use a particular Excel spreadsheet once a month. The file is saved on their desktop so they can find it easily. They need to access the file and modify it but is there a way to prevent them from changing the name or erasing the file. Any advice is appreciated.
Prevent User From Changing Author
i'm teaching my class excel and the students have to save their homework files to a network folder designated for them. i recently caught students taking copies of their homework files and transfering them via thumb drives to other students folders. the only reason i knew they did this was because i looked at the author property in file-properties and saw that the original author was not the user in whose folder it was in.
i have a feeling as soon as i confront the students about cheating they will be looking for how i found out and a way around this. you can easily change the author on a file and i was wondering if anyone knew of a way to prevent this. is there a registry entry that can be edited so that the author box is filled in automatically with the original user but can't be edited? any help would be very appreciated.
Prevent User From Typing In A Cell
I am trying to prevent a user from typing in a cell in Excel. I have tried to lock the sheet but this does not help as it still allows the user to enter edit mode in the cell. If I can't prevent the user from entering edit mode in a cell altogether then I need to know a way to end edit mode before the Excel window loses focus to another application. In normal manual use of Excel, ending edit mode can be done by simply having the user press the Escape key. This might work; however, I can't figure out how to trap the fact that Excel is losing focus or that the user is pressing keys in a cell. Could someone please help me as to the feasability of either preventing edit mode in Excel or ending edit mode upon each keypress or Excel loss of focus.
Any help would be greatly appreciated!!!
Context: Edit mode is preventing another application from continuing until the user switches back to Excel and ends Edit mode (if the user is in fact in the middle of editing a cell). This situation seems to be occurring because I have a module level variable in an Excel module which I am using (and need) to maintain a reference to this other application.
Prevent User Disabling Macro's??
i'v made a maximised userform that opens automatically on opening the excel file. it works great
this userforms takes the user through some steps to calculate some test-scores.
Problem : if the user disables the macro's, the file still opens AND it shows the underlying worksheets.
I DON'T WANT THAT TO HAPPEN!!
question : Can I prevent the user from opening my workbook if he/she doens't enable the macro's
Maybe even pop up a warning that they should enable macro's (although if they disable macro's it will be difficult to pop up anything at all)
How To Prevent The User From Typying Any Data ...
I am trying to prevent the user from typying any data to some field ( till some conditions will exist)
so i put some code in the "key press" event
the problem is that the user still can paste data by using the mouse ( right click and click on the paste ) or shift + insert
can you help ?
Prevent User From Moving Chart
I'm using MSchart in an application.
In the application I allow the user to select points on the chart. So I have to allow selections in the chart property window.
However if a user clicks on the chart, holds the button down, the user can drag the chart around inside the chart window.
And once the user has done that, he/she can now use the right mouse button and resize the chart itself.
I want to be able to allow the user to only select points on the chart. Nothing else.
Any help would be greatly appreciated.
How To Prevent The User From Add Dublication Data ???
peace be with you
i have table concest of (2) fields :
the data type of it :
1-auto nubmer ( premier key )
2- text ( 255 )
how i can prevent user from dublication the data in this field by ::
- make the second field (vb6_project) indexed ot it -- > no dublication
- the first field when i add will be new one like """ 1 , 2 , ... " but the data in vb6_project will be dublication
Prevent User Input Letters.
i have a text box which is suppose to key in decimal or integer..and not letters or commas etc... how do i prevent that?
Prevent User From Resizing A MDI-Form
How can I prevent a user from resizing a MDI-Form
above or below a specific size.
Also - is it possible to disable the maximize form button on a
Prevent User From Opening Another Program?
Is there any way to prevent a user from opening MS Access while using my program?
I don't want to create integrity errors from direct modification of the database while my program is open.
Prevent User From Closing Word
I need to disable the X in the right upper corner of Word and the X of the active document in the menu bar.
Basically I want to prevent the user from closing the document until certain circumstances have been met (a certain number of sections for example).
The idear was by exchaning the normal menu bar with my own and putting my own close macro into it I would be able to prevent people from closing the document until their work is done (evil me).
But this wont work if people are able to use the X buttons.
If both X buttons can`t be disabled at the same time:
Is there a way to stop the document_close event?
Or to use the close event to open the document again immediately ?
Please don`t sent code with the userform_queryunload event or "removemenu API calls" which work for normal Userforms and MDIchilds, because these don't work - tried a bunch of these already.
Prevent User From Disabling Macros
I have some code that I have written to password protect a workbook.
The problem I am experiencing is that if the user disables macros, then
it does not work. Is there a way to prevent the user from disabling
macros. Thanks for your kind help.
How To Prevent User From Closing My Application?
My application will take very long time to process data.
Sometimes user couldn't wait and close out my application while it was
transferring data. I don't know how could they close the application,
maybe using ctrl-alt-delete.
What event should I write code so that my application can exit
I need to clean some data before if the application got killed by user?
Your help is greatly appreciated!
Prevent User From Leaving Form
Is there a simple way to prevent the user from leaving a form. I can prevent user from leaving unless the user selects the X button on the form. I do not wish to remove the X but I want to trap for it if the user selects it.
How To Prevent User To Install Any Programs??
i think this is a stupid question, but i want to know how it works in my program.
i have a program that can prevent adjusting time in my pc but it works only in win98, in winxp it dont.
this time i want to know how to prevent any user of my computer to install there softwares or any kind program to my pc. pls. give me a simple code on how to work it.
i hope u can give a simple idea on it.....
Prevent User From Resizing Form
Yo yo yo
how can I prevent a user from resizing a form
I was thinking
Private Sub Form_Resize()
form1.width = 100
form1.heigh = 100
but is there anything better?
How To Prevent A User From Deleting A Specified Directory?
What's up guys. Just as the title states, I'm lookin for some code to prevent the user from deleting a specified directory. Similar to if you would try to delete an mp3 that Winamp or Windows Media Player is using. There has to be some way to make windows aware that that certain directory is in use. Thanks in advance!
Something That Will Prevent User From Loading My Program Twice
ok look, if i run my program once, it shows up, but if i run it again it shows up again and again and again, finally i can have 100s of same program running...how do I make it so that if my program had been loaded, user can't load it again, unless he closes the original (1st one)
How Do You Prevent Two Of The Same Items Of Data From Being Entered In A Combo Box
This is my code. What would i need to do to prevent to fileds with the same data from being entered
Private Sub Form_Load()
Dim Index As Integer
Dim Player As BlitzballPlayers
Dim PlayerstoDisplay As String
Dim PlayerName As String * 12
Dim Filename As String
Filename = App.Path & "Blitzball Player Stats.dat"
Open Filename For Random As #1 Len = Len(Player)
NumberofPlayers = LOF(1) / Len(Player)
For Index = 1 To NumberofPlayers
Get #1, , Player
PlayerName = Player.PlayerName
PlayerstoDisplay = PlayerName
Prevent User From Change Wallpaper/screensaver
Hi there. Is it possible to create a reg. file which can prevent user from changing wallpaper and screensave options instead of disable the index tags in admin. template? If yes, how?