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

Subform disappears Main form allowedits = false 1

Status
Not open for further replies.

kaiana

Programmer
Sep 6, 2002
85
AU
I have a main form with a tab control and several subforms. There has been many errors with accidentally hitting the space button when looking up data so I have set the main form to allowedits = false which also sets the subforms to not allow edits which is fine, except that, if the subform has no data for that particular record, the subform is not visible at all. Is there any way around this so that the subform is visible but empty?

Regards
 
kaiana

Hmmmm....

I dont seem to have this problem. I lock a record to prevent change to past transactios. Snippet of code is...

Code:
If Me.CommitOrder Then
    Me.AllowEdits = False
    Me.MySubForm.Locked = True
    '.....
Else
    Me.MySubForm.Locked = False
    Me.AllowEdits = True
    '......
End If

I prevent edits to the main form and lock the subform. (Have you found the draw back of this approach yet?)

An alternate solution is to lock specific fields, hide other fields. This may be the preferable solution actually since if you have unbound combo boxes used to find records, you will not be able to select from them to select specific records. (Bummer :-( )

I therefore create a subroutine on the form to toggle the form from locked to unlocked.

A boolean variable, booUpdate in this example, is set and then passed to the subroutine.

Snippets of code...
Code:
Private Sub SetScreen(booUpdate As Boolean)

Me.MyField1.Visible = booUpdate       'hide / unhide
Me.MyField2.Visible = [b]NOT[/b] booUpdate   'unhide / hide
Me.MyField3.Locked = booUpdate        'lock / unlock
Me.MySubForm.Locked = booUpate        'lock / unloack subform
...

End Sub

Note how the boolean variable can be used for True / False by including NOT to flip the value.

By toggling one variable, all appropriate fields can be locked / unlocked and hidden / unhidden with minimal maintenance.
Richard
 
Richard,

Thanks So much for your thoughts, sorry it has taken me so long to get back, I have been off the project for a couple of weeks. The first suggestion of yours was exactly what I needed and works beautifully. Thanks again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top