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

How to "POST" or "FREEZE" an Invoice form ?

Status
Not open for further replies.

acnovice

Programmer
Jan 27, 2005
100
US
I have an Invoice form with Invoice detail subform.
Once the Invoice form is created, I want to "POST" it to protect changing further.

When the invoice form needs to be changed, I will give a revision field.

Ex) Invoice Number : 1000
Changed after POST : 1000a

Any suggestion ?
Thank you.

 
If you want to 'lock' the data to prevent changes, you would need some field in the record that would indicate 'locked' (or 'POSTED'). If you have that field you could add code to set the field to 'locked'. Then in your 'Form_Current' event, if it is locked, change the form 'Allow Edits', etc.

If you're saying you want to prevent someone from changing the design of a form, you could create an MDE.

"Hmmm, it worked when I tested it....
 

Trevil,

Can I use Yes/No data type or Command button as a field indicated 'locked' ?

Could you give some syntax to set the field to locked ?
 
Place a button on your form, and in its click event, set the lock field to true.

In the form's update code, check the status of the lock field, and cancel updates if its set.

If you want to be nice to your users, give them some visual cue that the record's locked, so they don't waste time trying to edit it. I usually lock all the controls on the form, and gray the control backgrounds.

You can also make the button's control source the locked field, and the button will stay depressed when the field is set to true.

Hope all this helps.
Mark
 
Thank you for the reply.
Somebody opened a code to share and I tried that.

Gave a Toggle button on the form and created a sub routine that locks/unlocks fields of the form.
It works fine but I'm getting an error when I move to new record.

"Microsoft Visual Basic Run-time error '94': Invalid use of Null"

and error indicate --> SetScreen = Me.LockRecord

Code is following.

Private Sub SetScreen()

Dim SetScreen As Boolean

SetScreen = Me.LockRecord

Me.SoldTo.Locked = SetScreen
Me.ShipTo.Locked = SetScreen

'Set the Locked value for the entire subform

Me.sfrmInvoiceDetail.Locked = SetScreen

If SetScreen Then
Me.LockRecord.Caption = "Edit"
Me.LockRecord.ForeColor = vbBlue
Else
Me.LockRecord.Caption = "Locked"
Me.LockRecord.ForeColor = vbRed
End If

End Sub
 
It took me a few minutes...
Your database field is named 'LockedRecord'. So to avoid the 'Null' problem, use the following:

SetScreen = Nz(Me.LockRecord)

Also, your code to change the caption & loc is backwards.

Change the:
If SetScreen Then

to:
If Not SetScreen Then

The locked flag should indicate 'Locked', else you should name your database field 'Unlocked'.

"Hmmm, it worked when I tested it....
 
Trevil,

Thank you for the answer....
I changed the "SetScreen" to

SetScreen = Nz(Me.LockRecord, 0)

Now, I don't get any Null problem at all.
Also, thank you for pointing out backwards.

Have a good day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top