Lock Subform

G

Guest

I am trying to lock subforms for any data that is from a previous year.

I have a form using a query as a record source. There are six tabs and six
subforms in this form. The subforms each use different tables as record
sources.

When opened the form is on the first record in the query and the first
subform is visible (all others are set as me.formname.visible = false). The
first subform is general data on the selected record.

The six tabs are for: General Data, Year 1, Year 2, Year 3, Year 4, Year 5.
Where the actual year is listed (ie 2007-08). Not all the year tabs are
shown for all records.

Example
If the first record has a schedule of three years, then the only tabs
visible would be: General Data, 2006-07. 2007-08, 2008-09

To scroll through records, I set up previous and next buttons that use the
following:
DoCmd.GoToRecord acDataForm, "frmUpdates", acNext

I've tried the following:
1. Setting the On Load for subform Year1 where it looks at the current year,
and if the year in that subform is less than the current year, the form is
locked and disabled. This works great for the first record when the form
opens, but when I scroll to the next record, and the subform year is not less
than the current year, the record is still locked.

I'm assuming this happens because the subform never closes, thus it only
loads when the main form is opened?

2. Creating new fields on the main form: txtLock1, txtLock2, txtLock3,
txtLock4, txtLock5. Where the field is updated as either "Locked" or Null,
when the form loads, and when the the next/previous buttons are clicked. It
is marked "Locked" if the correlating subform's year is less than the current
year, and null if it is equal to or greater than the current year. Then in
the subform's OnCurrent, I had it say (For subform Year1)
if Forms!frmUpdate.txtLock1 = "Locked" then
me.allowedits=false
me.allowdeletions=false
me.allowadditions = false
endif

This gave me the same results as the other, where it worked for the first
record, but not the others.

Any help is greatly appreciated.

-Matt
 
G

Guest

I figured it out.

I set the OnClick for the next/previous buttons and the Form Load to:

CFY = DLookup("dteFiscYr", "tblFiscal", "ysnCurrent = True")
tFY = DLookup("First", "qryFYDist", "Expr1 = '" & Me.Expr1 & "'")
If tFY < CFY Then
Me.frmFirst.Enabled = False
Me.frmFirst.Locked = True
Else
Me.frmFirst.Enabled = True
Me.frmFirst.Locked = False
End If

where CFY is the actual current year, tFY is the individual form's year, and
frmFirst is the subform for Year 1.

Then repeated this for the 5 year subforms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top