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

Block data entry/edit based on Status

Status
Not open for further replies.

ragu111

MIS
Aug 15, 2002
129
AE
in my form i have a field called "Status"

If the Status = "Open" user can edit the data on the form and subform

and if the Status = "Closed" i want to Block any data Entry, Edit on the form and subform

How can i do this

Ragu [pc]
 
ragu111 . . .

Try this in the [blue]Load[/blue] event of the form:
Code:
[blue]   Dim flg As Boolean
   
   If Me!Status = "Open" Then flg = True
   Me.AllowAdditions = flg
   Me.AllowDeletions = flg
   Me.AllowEdits = flg[/blue]

Calvin.gif
See Ya! . . . . . .
 
it's working but when i moved to next record i'm not able to update the record even the status reads "open"

i also tried the code with form_current event. same problem

one more thing i noticed is i have a fram with option in my form. that can be changed. the above code is not woking for the frame

Ragu[pc]
 
ragu111 . . .

Oh . . . so you do want record by record control . . .
Code:
[blue]   Dim sfrm As Form, flg As Boolean
   
   Set sfrm = [[purple][b]YourSubFormName[/b][/purple]].Form
   If Me!Status = "Open" Then flg = True
   
   [green]'MainForm[/green]
   Me.AllowAdditions = flg
   Me.AllowDeletions = flg
   Me.AllowEdits = flg
   
   [green]'subForm[/green]
   sfrm.AllowAdditions = flg
   sfrm.AllowDeletions = flg
   sfrm.AllowEdits = flg
   
   Set sfrm = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
to be more clear my subforms are placed in many Tab Control [TabCtl44]. where i'm getting a error in

Set sfrm = [TabCtl44].Form

also my 1st record status is "Closed" and i can't update any field. but when i moved to next record also i can't enter any field where the status is "open"

Ragu [pc]
 
ragu111 . . .

to be more clear . . . in:
Code:
[blue]   Set sfrm = [[purple][b]YourSubFormName[/b][/purple]].Form[/blue]
[purple]YourSubFormName[/purple] is just that! . . . I thought it was simple enough . . .

Calvin.gif
See Ya! . . . . . .
 
ragu111 . . .

Code should be in the OnCurrent event of the form . . .

Calvin.gif
See Ya! . . . . . .
 
below is my code... when i moved to next record which is on Open status also blocked. is anything wrong on below Code?


Code:
Private Sub Form_Current()

Dim SFRM As Form, FLG As Boolean
   
   Set SFRM = CusChargesSubform.Form
   If Me!Status = "Open" Then FLG = True
   
   'MainForm
   Me.AllowAdditions = FLG
   Me.AllowDeletions = FLG
   Me.AllowEdits = FLG
   
   'subForm
   SFRM.AllowAdditions = FLG
   SFRM.AllowDeletions = FLG
   SFRM.AllowEdits = FLG
   
   Set SFRM = Nothing
End Sub

Ragu [pc]
 
Code:
[blue]Change:
   Set SFRM = CusChargesSubform.Form
To:   
   Set sfrm = [red][b][[/b][/red]CusChargesSubform[red][b]][/b][/red].Form[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top