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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I set up a text box so that users can add, but not change? 1

Status
Not open for further replies.

keun

Technical User
Jul 15, 2005
262
US
I have a form that is used to look up existing projects, and to add new projects. I only want users to be able to add projects, not edit or delete existing.

Is this possible?
 
The form has Allow Edits, Allow Deletions, and Allow Additions settings on the property page (Data tab) that you can look into, but be sure that the user understands what is going on. It could be confusing if the user sees the control and tries to change the data, but Access doesn't allow it.

(I'm assuming that the form will be displaying existing data as well as creating new data, but I might be wrong on this.)

One way to handle it is when you open the form to an existing record (if that will be allowed) disable all the controls so they can still view the data. Another approach, if the form will only be for new data (not looking at old), is to set a filter to prevent the display of any existing records in the form when it's opened.

 
How are ya keun . . .

Try the following in the forms [blue]On Current[/blue] event:
Code:
[blue]   Dim flg As Boolean
   
   If Me.NewRecord Then flg = True
   Me.AllowEdits = flg
   Me.AllowDeletions = flg[/blue]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Have you looked at the methods that the built in switchboard uses? such as 1 tab/button for add new XXX and another for view XXX with the view locked so your users cannot edit.

----------------------------
Hill?? What hill??
I didn't see any $%@#(*$ Hill!!
----------------------------
JerryReeve
Communication Systems Int'l
com-sys.com

 
Thanks for the feedback all. I am going to try AceMan's suggestion today.

The reason that I need to view and add on the form is that this form contains a look-up function to confirm that an existing customer is not already entered. Once the user confirms such, the user can enter the new customer. What I don't want is for someone to open the form and start hammering away on an existing entry, nuking the data that was in there.

 
I am here to report back that AceMan's solution worked like a champ!
 
jerryreeve . . .

I posted what I knew would work off the top of my head, however, just like in math where you reduce to lowest terms ... the code can be reduced to just two lines:
Code:
[blue]  Me.AllowEdits = Me.NewRecord
  Me.AllowDeletions = Me.NewRecord[/blue]

Cheers! [thumbsup2]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top