473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to lock field/records associated with a combo box selection

Hello, I am having a difficult time locking a field/records that are only associated with the currently selected item in a combo box. A subform generates specific titles based on a combo box selection (for example, the titles are all sci-fi). In the next instance, I give users the ability to enter in values in a field in the subform, and a submit button would then lock all of the records so no further changes can be made by them. However, I can implement a lock feature that locks titles, but it ends up locking all of the records, and not just the records associated with the combo box.
- How do I reference specific fields/records based on a combo box in VBA
- Additionally, how do I compare records within the same combo box selection to ensure no two items in the same field have the same value?


Example code I'm trying to use:
Private Sub Submit_Click()
Dim Msg, Style, Title, Response, Mystring
Msg = "Do you want to submit?"
Style = vbYesNo
Title = "Submission"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Mystring = "Yes"

'This is where I would try to use the lock property of a field and lock based on what the combo box selection is
If Me.fsubtitles!Priority.Locked = False Then
Me.fsubtitles!Priority.Locked = True
Else
Me.fsubtitles!Priority.Locked = False
End If
Else
Mystring = "No"
End If
End Sub
Feb 6 '17 #1

✓ answered by Seth Schrock

Only one question is allowed per thread, so I'll answer the one related to the title of the question and you can ask your second question in a new thread.

If you change the property of a control on a form or report, that property is changed for all records being displayed, as you have discovered and this can't be changed. However, hope is not lost. What you can do is to create another field to mark those records which should be locked and those which can be edited. Then in your control's Before_Update event, you can check if the record is locked and cancel the change if it is while providing a message stating the reason for the cancellation.

1 1461
Seth Schrock
2,965 Expert 2GB
Only one question is allowed per thread, so I'll answer the one related to the title of the question and you can ask your second question in a new thread.

If you change the property of a control on a form or report, that property is changed for all records being displayed, as you have discovered and this can't be changed. However, hope is not lost. What you can do is to create another field to mark those records which should be locked and those which can be edited. Then in your control's Before_Update event, you can check if the record is locked and cancel the change if it is while providing a message stating the reason for the cancellation.
Feb 9 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alex | last post by:
Acc97.. I have a database which records down-time on 8 machines, the selection of reasons comes from a combo box. I have tried to be clever! and limit the options relative to each machine within...
2
by: CSDunn | last post by:
Hello, In an Access 2000 ADP subform, I have a set of two Radio buttons in a single group that are bound to a field called 'Completed'. The Completed field comes from an SQL Server 2000 table, is...
1
by: DD | last post by:
I have a mainForm with a subForm On the main form i have a combo with March 04, April 04 etc, you select a date and the subform shows all records for the selected date. I can print a selected...
1
by: flamethrower01 | last post by:
Hi, I have a form (with 4 subforms) which is filtered by 3 combo boxes. Upon loading the form, the form populates fine. After the first combo box, the form works fine. After the second one...
2
by: kennygee | last post by:
I am trying to learn VB after many years programming in Access. I am trying to do something in VB that is simple in Access. How do I display record data on a form based on the selection made in a...
1
by: apprenticewizard | last post by:
Please help....been at this for several days and just can't seem to find a solution. I've got two tables, Emp Info and Labor Records. The form to populate the Labor Records table contains a combo box...
4
by: sheraz1 | last post by:
Hi, I am new to VBA, I am trying to create a form that will take the DISTINCT values of a one column and then display all the records associated to that value in the form. I am not sure...
8
by: lulu123 | last post by:
I have a database, which keep track of the hours employee worked. The employee enter the hours monthly. The table is set to like, Project/ Month/ Hour/ what i want to do is: I want to lock...
3
by: geraldjr30 | last post by:
hi, i have the following, which lists days of the week, and records associated with each of them from an MS Access table. i would like to know how to display the count of the records associated...
4
by: dekk | last post by:
I am trying to populate a text field from the combo selection. I have the following update event in the combo box Private Sub cboContract_AfterUpdate() Me!txtDesc = Me!cboContract.Column(1)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.