Locking a combo box

I set a combo box to enabled yes and locked no and I have no problems picking 
a value. My combo box is bound to a table. The problem is I can type over the 
value in the combo box and change the value in the table.
I would like to pick a value and subsequently like lock the combo box.
Thanks,
Stanley
0
Utf
11/13/2009 5:08:06 PM
access.formscoding 7493 articles. 0 followers. Follow

5 Replies
607 Views

Similar Articles

[PageSpeed] 18

Stanly,

If you lock the combo box once the user has entered data, how will they ever 
correct it?

Given that, you might try this. I don't know if it will work.

on the field's Got Focus event, add this code:

If inNull(ComboBoxDataFieldNm) then
    me.cboCtlNm.Enabled = True
    me.cboCtlNm.Locked = False
else
    me.cboCtlNm.Enabled = False   
    me.cboCtlNm.Locked = True
end if

on the field's Lost Focus event, add this code:

me.cboCtlNm.Enabled = True   
me.cboCtlNm.Locked = False



I don't know if that will work, I would give it a try.

-- 
Dennis



0
Utf
11/13/2009 6:21:01 PM
Stanley wrote:

>I set a combo box to enabled yes and locked no and I have no problems picking 
>a value. My combo box is bound to a table. The problem is I can type over the 
>value in the combo box and change the value in the table.
>I would like to pick a value and subsequently like lock the combo box.


Use code in the form's AfterUpdate event to lock the combo
box:

	Me.thecombobox.Locked = Not IsNull(Me.thecombobox)

What is a user supposed to do if the wrong value was picked?

-- 
Marsh
MVP [MS Access]
0
Marshall
11/13/2009 6:25:16 PM
As has already been noted, your proposed scenario has a problem in that users
do make mistakes, especially when picking a value from a combobox while in a
hurry, and locking the cbo prevents them from correcting their mistake.

You also mention a user typing over an existing value and changing it in the
underlying table, but make no mention of them using the combobox to change a
previous selection.

Is it simply the typing in of a different value, one not in the combobox that
you want to prevent? There are several ways to do this. One would be to

1) Add a textbox to your form and bind it to the underlying field, not the
combobox

2) In the textbox properties sheet, set Locked Property to Yes

3) Use code like this in the cbo's AfterUpdate event:

Private Sub YourComboName_AfterUpdate()
  Me.TargetTextBox = Me.YourComboName
End Sub 

The data in the TargetTextBox cannot be overwritten by the user, but they can
remedy a mistake made with the cbo by making another selection.

-- 
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200911/1

0
Linq
11/14/2009 12:01:58 AM
Marshal,

I'm still learning Access, so please permit a couple of questions from a 
student.  I understand placing the code you suggested in the form's After 
Update event.  Here are my questions:

1.  What happens when the user goes to enter the next "transaction" during 
the same session?  The combo box will have been disabled by the Form's After 
update so they will not be able to enter anything in the combo box for the 
next or subsequent transations in that session.

2.  What happens the next time the user enters the form in a different data 
entry session and the first thing they pulls up is a prior transations?  
Since the Form's After Update has not yet run, they will be able to change 
the value in the combo box.

Thanks for the information.

-- 
Dennis



0
Utf
11/14/2009 12:14:01 AM
Same answer to both questions.

Whatever logic you've got in the AfterUpdate event needs to be invoked in 
the form's Current event so that as you move from row to row in the form, 
Access determines whether or not the current row needs to have its combo box 
locked or not.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Dennis" <Dennis@discussions.microsoft.com> wrote in message 
news:F6677232-1FD1-4F26-85AE-E3820D185E4B@microsoft.com...
> Marshal,
>
> I'm still learning Access, so please permit a couple of questions from a
> student.  I understand placing the code you suggested in the form's After
> Update event.  Here are my questions:
>
> 1.  What happens when the user goes to enter the next "transaction" during
> the same session?  The combo box will have been disabled by the Form's 
> After
> update so they will not be able to enter anything in the combo box for the
> next or subsequent transations in that session.
>
> 2.  What happens the next time the user enters the form in a different 
> data
> entry session and the first thing they pulls up is a prior transations?
> Since the Form's After Update has not yet run, they will be able to change
> the value in the combo box.
>
> Thanks for the information.
>
> -- 
> Dennis
>
>
> 


0
Douglas
11/14/2009 11:59:45 AM
Reply:

Similar Artilces:

option buttons or check boxes
I am fairly new to VBA and trying to learn on the fly. I have a spreadsheet with 4 sheets, each with its own name. I want to create 4 check boxes or option buttons on the first sheet. I have print button. I want to have it so when you check a box and hit the print button, only that sheet will print. If you check all 4, all 4 print, etc. Can anyone help? Thanks! -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/excel-new/200608/1 meandmyindigo via OfficeKB.com wrote: > I am fairly new to VBA and trying to learn on the fly. I have a > spreadsheet with...

How to set locks to 0
HI Under SQLServer2005 Advanced Properties - Parallelism, I need to set Locks to zero (0) because I suspect that 5000 locks that it shows actualy, have triggered the following error: "the instance of the sql Server Database Engine cannot obtain a LOKC resource at this time. Rerun your statement when there are fewer users...." I appreciate all your wise suggestions. LAM LAM (luism0@(arroba)yahoo.es) writes: > Under SQLServer2005 Advanced Properties - Parallelism, I need to set > Locks to zero (0) because I suspect that 5000 locks that it shows > a...

Text box link / Copy
If I have a textbox that then sends the text to another textbox if there is to much, is there a way to have the 1st textbox say something along the lines of 'see articles xx on page 3', and have it show up automatically? There is the option to "continue on page xxx" Right-click the text box, format text box, Text Box tab. You will not see this option unless the first text box is full and there is overflow. You can change the wording once it is visible. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Steve...

Locking Chart in Place
Is there a way to lock a chart in place so that it cannot be dragged from its current location? ...

Field availability dependant on combo box choice
Hi, I have created a database that will be used amongst other things to raise purchase orders (PO). On my PO form I have a combo box which the user uses to specify if the order is for consumables, hire weekly, hire daily and delivery. What I want to happen is that if they pick either hire weekly or hire daily the field next to it becomes available into which they can specify the number of days / weeks, however if they chose any of the other options, the field is not accessible, or hidden. I know the answer is probably already listed somewhere, I'm just not sure what ...

GetLBText( ) only apply for Dropdown List Combo?
Hi, I saw the manual that GetLBText( ) only apply for Dropdown List Combo, but I used the function to the dropdown combobox(not a droplist combobox)on my program, I found it did also work well. Why? Thanks a lot Julia "Julia" <anonymous@discussions.microsoft.com> wrote in message news:034001c3d624$691f46d0$a301280a@phx.gbl... > Hi, > I saw the manual that GetLBText( ) only apply for > Dropdown List Combo, but I used the function to the > dropdown combobox(not a droplist combobox)on my program, > I found it did also work well. > Why? I don't think it...

Linking of Cell value to a text box
Is it possible to refer a cell and/or more than one cell to a text box? If yes, please tell me how to do that. In case it is possible to refer more than one cell to a text box, then it would require flexible text box. I mean when more data is required to be put in the same text box, its boundaries should be flexible to accommodate the data of more than one cell that have been referenced/linked to the text box. Please Help. Thanks in advance Sudhanshu --- Message posted from http://www.ExcelForum.com/ If you want the value of a cell to appear in a textbox and be linked such that if the v...

vertical center alignment of text in Edit box
Hi I want to vertically center align the text in a edit box (CEdit Object) as text is getting entered in the text box irrespctive of the font size. Can anybody help in this matter? As far as I can tell, this is impossible. There is no support for it. I once had someone describe a means of doing this: you use DrawText and use the vertical-center option in a plain CWnd. Then, if someone clicks the mouse on the text, just like a spreadsheet, you create a borderless edit control at that instant that has the same text in it, and this is placed so the effect is invisible to the user. In the O...

Outlook 2002 locked up when deleting contacts
Hello- While cleaning out duplicates and obsolete email addresses, Outlook locked up on me. I used the task manager to end the program and then shut the machine down. I rebooted and Outlook asked if I wanted to start up in safe mode. Did that, Outlook just sat there. Used the task manager again to quit outlook. Tried rebooting again. Outlook comes up, but the cursor is constantly the hour-glass and I can't do anything with in the program. Any ideas for fixing this? Thanks. Close Outlook. Find and rename outcmd.dat to .old. (If using Windows 2000 or XP, you will need to e...

Default font for pasted text in text boxes
I am having a problem with text boxes in Excel 2007. When I copy text (in Arial font) and paste it in the same text box, it appears as Calibri. I would like it to appear as Arial, just as it was when I copied it. I followed the directions for setting default font in new workbooks to Arial, and I have this problem even in text boxes within new workbooks. I do not have the problem outside of text boxes within new workbooks. I also followed the directions for setting default text box style, and new text boxes have Arial as their default font, as they should. However, when I ...

Changing Text Box Size and Location on a form, at run time with Access Xp
Hello All, Is it possible to change the size of the text box (or any other control) on a form at run time, by Drag and drop or resizing borders using the mouse events. (Just like the design mode but the user will use it at run time on form view). Thanks in advance... You should be able to resize in your code if necessary. Me.control.Visible = True Me.control.Height = 1000 Me.control.Width = 1000 Don't forget to set them back when you are done. "Developer" wrote: > Hello All, > Is it possible to change the size of the text box (or any other control) on > a ...

Transparent Box
I have a chart where it was requested to put a transparent box with diagnal lines over half of the chart area. I did this by creating a box, selecting fill effects, and making the box transparent. It prints fine on any black and white printer but ends up solid when I try to print to either a color printer or a color copier. Do you have any idea what I should do? Thanks, ...

Excel should let me create an automated list of the name box
When the name box is used to link cells from other worksheets, or to link matrices to a single name, for lots of data, one can get lost as to what name links to what cell/group of cells, especially if it is a "hand-me-down" spreadsheet. Is there a way to make an automated list that shows you the name and what cell(s) it links to instead of going through "Insert>Name>Define" and copy the name, paste in Word, then go back and copy the "Refers to" field and re-paste in Word, n-times? ---------------- This post is a suggestion for Microsoft, and Microsof...

Simple Question............Deleting "Name Box" name!
Hi, Say you have a range named "ABC" in Name Box. How do you delete it? Thanks, Mike XL prior 2007: Insert>Name>Define> PICK YOUR NAME > Delete On 4 Dec, 14:58, Mike <mas_it_2...@yahoo.com> wrote: > Hi, > > Say you have a range named "ABC" in Name Box. How do you delete it? > > Thanks, > Mike ...

I want to inhibit editing of one text box based on the content of another
The two text boxes are on the same form (subform3). I want to inhibit the Quantity filed from being edited if the Status field contains "Ship Requested". The following code gives me an error 'Expected: list separator or )' Private Sub Quantity_BeforeUpdate(Cancel As Integer) ' Inhibit txtbox if the Status field is "Ship Requested" IIf(me.Status = "Ship Requested"; me.AllowEdits = True, _ me.AllowEdits = False) End Sub On Fri, 27 Nov 2009 23:07:21 -0500, BobC wrote: > The two text boxes are on the same form (subform3). >...

Expand Combo box
I have a ComboBox (cboClient) that searches the form for a specific record. I would like for the combo to expand when the user begins to type so that they can see where they are in the list. As it is right now, the user must begin typing and then click the arrow to expand the box. Any help is appreciated! Tara Tara wrote: >I have a ComboBox (cboClient) that searches the form for a specific record. >I would like for the combo to expand when the user begins to type so that >they can see where they are in the list. As it is right now, the user must >begin typing and the...

combo box text is blank
I have a timesheet form. I have fields jobNumber and WorkCodeID. JobNumber has a description which displays only when selecting from the combo box. The job number displays on the form. The workcodeID works a little different. The workcodeID has a description which I want to display on the form, not the id. The code for my workcodeID combo box says display the description not the code, but bind the combo box workcodeID to the form workcodeID. I hide the workcodeID setting the column widths of the combo box to be 0cm;5cm etc. Now when I load the form, the historical records for w...

how to add text box
Is it possible to add a text box to a document, but without the black border around the text box? It is. Double-click the border of your textbox, then, under "Line", select the colour you'd like to use, or simply use "No line" to get rid of the lines altogether. On 29/11/06 9:45, in article 1164789931.183526.112550@h54g2000cwb.googlegroups.com, "lawengin" <skho@iinet.net.au> wrote: > Is it possible to add a text box to a document, but without the black > border around the text box? > -- Michel Bintener Microsoft MVP Office:Mac (Entourage...

Lock a Table
Hi All, Is there a convenient way to programatically allow the current user to have full access to a table in the current db, while preventing other users from accessing it until the program releases it? -- Mac C. Thanks Larry, I should probably be more specific. The table is used for temp storage of records that will be accessed by another application (MsWord via merge mailing). A form in the database is bound to the table. When the form opens it invokes a public procedure that deletes all records in the table and rebuilds it from scratch. After that proc returns, the form requi...

Combo Boxes #8
I have built 3 templates of which 2 work perfectly. The 3rd one has m puzzled. Below is a copy of the result I'm trying to get from my comb box. Game Description Value Comments 4 1 Select 0 2 5 Pin 5 Pin 5 Pin Lanes 3 10 Pin 10 Pin 10 Pin Lanes 4 Custom test I select 1,2,0r 3 & I get my proper result. When I choose Custom I ge the result for 3. I've checked the assignment unde "insert","name","define"& that is alright. I've checked the assignmen for the combo box itself & it is alright. The Formul (VLOOKUP(Bowling!$E$!,Game,...

How to filter combos during data entry
I'm trying to track the shapes (number of dimensions) and values of variables called "assumptions" to be fed into cash flow and credit models. I have an "Assumption Master" table of all assumptions that tells me whether they have one, two or three dimensions, and a "Dimension Lists" table telling me what each dimension could be. For example, an assumption called "Product Lien Factor" has two dimensions called "Lien Position" and "Rating": Lien Position could be 1 or 2, and Rating could be AAA, AA+, AA, AA-, A+, A, ...

List Box
I have list box with multi Column, how can I allow the user edits the fields? "Mohammed" <Mohammed@discussions.microsoft.com> wrote in message news:F9CA0560-223D-4379-8B6E-4A8277F8755F@microsoft.com... >I have list box with multi Column, how can I allow the user edits the >fields? A list box is not editable; use a subform in continuous or datasheet view instead. -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup) Or, if you decide to keep a list box, you could put code in the list box's...

List box asks for parameter when I do DoCmd.Close
I have a form for taking questions in a questionnaire. There is a list box on the form which shows possible choices based on the question number which is in another text box. The question number is referenced in the list box's data source query in the form Forms!frmSurvey!txtQuestionno. It works except when I do a DoCmd.Close on the form I get a popup asking me for the parameter value Forms!frmSurvey!txtQuestionno. This does not happen when I click on the X to close the form. Why am I getting a parameter popup on DoCmd.Close and how can I get rid of it? Robert zie: http:/...

making charts with boxes to write in
Is there a question? - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions http://PeltierTech.com _______ "Patsyspencer@sadie66762" <Patsyspencersadie66762@discussions.microsoft.com> wrote in message news:7CEFC048-A8E5-4D63-B050-7EAA723560AE@microsoft.com... > ...

HELP: Starting a cascading combo with no records!
The purpose of this is that In a form I have two bound combo boxes: Combo 1 is for customer name and Combo 2 is for first line of address. Combo 1 source: tble_customer Combo 2 source: tble_branch Each customer can have many branches I have inserted VBA into the "not in list" event in the form to add customer names to "tble_customer" which works fine. I created an append query that would append combo 1 and combo 2 to "tble_branch" but I get a key violation. How can I otherwise make sure the address I type goes with the correct customer name. I've...