Results 1 to 3 of 3
  1. #1
    trb5016 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Location
    Pennsylvania
    Posts
    71

    Pass a form property to a procedure


    Imagine this:

    Code:
    Sub SetFormsProperty(FormName as Form, FormProperty as [??????], Status as Boolean)
    'Sets a boolean property on a form and all of it's subforms
    
    FormName.FormProperty = Status 'i.e. StaffDirectory.AllowAdditions = True
    
    
    'Code to apply the same to each of the subforms
    'I have this down
    
    End Sub
    Is this possible? I want to be able to pass .AllowAdditions or .AllowDeletions etc

    I've tried dimensioning it as a property and as properties but that doesn't work (I don't really know if that makes sense)

    Any ideas?

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Setting AllowAdditons & AllowDeletions for a form is quite easy, use

    Code:
    Me.AllowAdditions True
    Me
    .AllowAdditions False
    Me
    .AllowDeletions True
    Me
    .AllowDeletions False 
    of
    Code:
    Forms!YourFormName.AllowAdditions True
    Forms
    !YourFormName.AllowAdditions False
    Forms
    !YourFormName.AllowDeletions True
    Forms
    !YourFormName.AllowDeletions False 
    as the case may acquire for a form.

    Similarily, for a subform
    Code:
    Forms!FormName!SubformName.form.AllowAdditions true 
    etc.

    If your really don't know the subforms associated with a form, you cycle through the main forms controls checking each control's data type and for each subform data type encountered, set that subforms AllowAdditons, AllowDeletes property as appropriate. Lookup and search this form for searching a form controls. I'm not big on giving people code.

    If you need to do all this is a subroutine, which is not necessary, you subroutine reference is
    Code:
    Sub SetFormsProperty(FormName as FormFormProperty as StringStatus as Boolean)
    forms(formName).(FormProperty)=Status
    'cycle through form's control container as indicated above
    end sub 
    Why not just use
    Me.AllowAdditions = true
    forms!YourformName!YourSubformName.form.AllowAddit ions=True

  3. #3
    trb5016 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Location
    Pennsylvania
    Posts
    71
    Code:
    Sub SetFormsProperty(FormName as Form, FormProperty as String, Status as Boolean)
    forms(formName).(FormProperty)=Status
    'cycle through form's control container as indicated above
    end sub
    This is just what I was looking for, thanks.

    I have the cycling through the forms all set and working great. It's just I have to do this with a lot of different properties working with several different conditions.

    The subroutine will make the code a lot cleaner

    Thanks again

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Pass data from one form to another
    By Bruce in forum Forms
    Replies: 16
    Last Post: 02-25-2013, 03:59 PM
  2. Pass a Parameter From a form to a Query
    By DDillesha in forum Forms
    Replies: 1
    Last Post: 10-28-2009, 12:49 PM
  3. Replies: 0
    Last Post: 10-04-2009, 04:11 AM
  4. stored procedure return value to access form
    By rbw940 in forum Programming
    Replies: 0
    Last Post: 10-13-2008, 01:31 PM
  5. Replies: 0
    Last Post: 03-19-2006, 11:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums