Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking a single field 2

Status
Not open for further replies.

Smack

Technical User
Apr 20, 2001
261
US
I have an mdb in which I uploaded 2500+ records into a table. These records did not have all the data fields completelt filled out, and other new fields were added as well. Because of this, individual records require editing, and as customer requirements change, data will require further editing. I have one field, the product item number, which is unique to each record. Once this field has been filled out, how can I lock this single field from being edited?
-Smack
PS - I cannot write SQL or code.
 
You can lock it out on your form. It will still show on the form, but the user will not be able to click on it or change it. Just goto the properties for that text box on your form and click on the "data" tab, then look for "locked" and change from "no" to "yes". I think this is what your wanting.

Craig
 
HI,

In the product item numberafterupdate event simply insert the following statement Modify as needbe:

txtProdNum.locked = true

This will lock the textboxcontrol from being edited.

Have a good one!
BK
 
Hi esu4edp,

Actually, your solution won't work in this case since the user has to get the product item number into the field first. <g>

Have a good one!
BK
 
BlackKnight is correct, and I should have added that to begin with. The product item number is a new field, so many records have to have this entered for the first time.
-Smack :-(
 
Hi again,

I was too hasty and we all know what that means...<g> Better is

Private Sub PaidDate_AfterUpdate()
If Not IsNull(txtProdNum) Then txtProdNum.Locked = True
End Sub

Private Sub Form_Current()
If IsNull(txtProdNum) Then txtProdNum.Locked = False
End Sub

Have a good one!
BK
 
Thanks for the response BK,
I'm going to go out on a limb and assume this is in code. I have never used code, so what do I do? If this is too much of an undertaking I understand.
-Smack
 
Hi,

Yes, it is in code.

1) Open your form in design view
2) Right click on the little black sqaure in the upper lefthand corner of the form.
3) Click on Properties.
4) Click on the EVENT tab. Click in the ON CURRENT property.
5) Click on the down arrow and select [Event procedure] from the list
6) Click on the ellipsis (3 dots). (you'll be in the ON CURRENT event procedure.
7) Copy and paste this text:
If IsNull(txtProdNum) Then txtProdNum.Locked = False

into the procedure so that you end up with somthing like this:

Private Sub Form_Current()
If IsNull(txtProdNum) Then txtProdNum.Locked = False
End Sub

8) Move the cursor onto a blank line anywhere below the &quot;End Sub&quot; line

9) Copy and paste this text onto the blank line:

Private Sub txtProdNum_AfterUpdate()
If Not IsNull(txtProdNum) Then txtProdNum.Locked = True
End Sub

NOTE if your textbox control is named differently than &quot;txtProdNum&quot; then simply change txtProdNum to your textbox name

10) Click on Save (the little diskette in the toolbar)

11) Close the VB module by clicking on the topmost close button (X)

12) Save the form in design view in the usual manner.

Have a good one!
BK
 
BK, the following scripting error was returned;Private Sub Form_Current()
If IsNull(MOVEX ITEM NO T.Movex Item No) Then MOVEX ITEM NO T.Movex Item No.Locked = False

End Sub
Private Sub MOVEX ITEM NO T.Movex Item No_AfterUpdate()
If Not IsNull(MOVEX ITEM NO T.Movex Item No) Then MOVEX ITEM NO T.Movex Item No.Locked = True
End Sub
Is this because of the periods from the field name? This field/form is pulled from a query.
 
Periods (dots) in a name are a verrrrry bad thing. Spaces in a field name require a[field name] (brackets) around it. Don't use ! or [ or ` in a field name either.
 
Well... in a test environment I changed the query so the field was just Movex Item No, but when I replace the field name from BK's example, I still get compile errors. I tried removing the space (no errors but the code did not work, adding []brackets around the field, but in the second series of code it was looking for something to the left of the[. I also tried replacing the space with Movex_Item_No, no errors but the code did not work.
 
Try the following for the the first function and see if that works:
Code:
Private Sub Form_Current()
   If IsNull([MOVEX ITEM NO T].[Movex Item No]) Then 
      [MOVEX ITEM NO T].[Movex Item No].Locked = False
   End If
End Sub
Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Hi,
Query? There is no need to change your query or its field names.

What is the name of the textbox control you are inputting the product number into on the form? Is it: &quot;Movex Item No&quot; ? If it is then you have to use brackets around it since it has spaces in its name this is what the code should be using this control name:

Private Sub Form_Current
If IsNull(Me![Movex Item No]) Then Me![Movex Item No].Locked = False
end sub

Private Sub Movex_Item_No_AfterUpdate()
If Not IsNull(Me![Movex Item No]) Then Me![Movex Item No].Locked = True
End Sub

Replace the code you entered with this code.

Have a good one!
BK
 
Man you guys ARE GREAT! Terry i did not try yours because I wanted to follow through with BK's help first.
BK - that did it. When I get everyone off of the live system I will make the modification.
Once again thanks for all the help.
-Smack s-)
 
Great Smack. No probs in trying his first. Just as long as you found success... Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top