Locking existing records in form

CrazyKillerMan

Registered User.
Local time
Today, 12:30
Joined
Nov 26, 2002
Messages
23
Hello

I have a form that is populated with data from a table. The form's entry's are bounded to the fields in that particular table. My problem is, I want the user to be able to veiw existing records, but when they make a change I want to force a new record and NOT save changes to the current record.

Is there anyway to do this?
I was thinking on click event but then that would create a new record on whatever section the user clicked on (may have to click multiple times on one form).

Another small problem with this is that I have default values for a good chunk of the fields on the form.

What is the best way of doing this? I found some suggestions searching the forums,
here but its a little to vague.

Do I have to have the fields unbounded then update then on a cmd button press??? Is that what the practice is? And if so, how does one bind fields with a cmd button?

Sorry if thats alotta questions - but thats me - full of it.
 
I have a similar situation - I want my users to view previously posted entries, but not be able to edit them.

So, for the OnCurrent event for the form, I placed code:

if me.newrecord then
me.field1.locked = true
me.field2.locked = true
etc.

else

me.field1.locked = false
etc.

end if

I only have 5 controls on my form, so I enumerate them here...if you have a lot of controls, you can place a loop in the code to globally change the Locked property.

Do you think this will do the trick?
 
Ok - I'm sure this will do what I want. I just have a few newbie questions.

When you say "me.newrecord" is 'me' the table or the form? and is it the same when you say "me.field1.locked = true "?

OK...now - how do i get to the OnCurrent event? I tried going to properties of the form, but it wasnt there. Is there something I am missing here?

Thanks for the reply
PS-Sorry for the late response, I've been down with a flu.
 
I took this from Access Help:

The Me property contains an object reference to the current form or report and is faster than a fully qualified object reference. For example, the following two code fragments refer to the value of the LastName control for the current record on the Employees form:

strLastName = Forms!Employees.LastName

strLastName = Me!LastName

The OnCurrent event is a form event that you will find under the form's properties under the Event tab.

HTH
 
Thanks for clearing up that 'Me' thing. Been wondering that for a bit.

As far as the on current event, all I have where you suggested to look is On Click, On Dbl Click, On Mouse Down, On Mouse Move, On Mouse Up

? This is obtained by right clicking the form (where there are no objects) in design view and going to properties ?

And....now understanding the Me syntax, I looked more closely at your code:
So, for the OnCurrent event for the form, I placed code:
if me.newrecord then
me.field1.locked = true
me.field2.locked = true
etc.

else

me.field1.locked = false
etc.

end if
Shouldnt the if me.newrecord then loop have = false?
ie:
if me.newrecord then
me.field1.locked = false
me.field2.locked = false
etc.

else

me.field1.locked = true
etc.
 
Last edited:
One way to view the form properties is to select View/Properties from the menu bar.

Another way is to double click on the box in the upper left hand corner of the form.

You're right about reversing the code to show unlocked for new records and locked for old records.

You don't need to place "'= true" after .newrecord, but you can if you want.

Cheers,

E
 

Users who are viewing this thread

Back
Top Bottom