UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Setting New Form Properties When Designing New Forms, Office 2007    
 
   
Aquadevel
post Feb 23 2012, 02:43 PM
Post #1

UtterAccess VIP
Posts: 6,902
From: Earth...



Hi My 'Utter Friend's,

I'm sure some one has done this.

When creating new forms for an app, its a pain to select like:
Close=no
Min/Max=no
Etc,

When creating new forms, I need a 'quick' way to select a form and change all the settings I need.

Someone must have an idea.... iconfused.gif


--------------------
Aqua

:cool: Sharing is caring :cool:
Go to the top of the page
 
+
rbianco
post Feb 23 2012, 02:56 PM
Post #2

UtterAccess VIP
Posts: 1,731
From: Carrollton, TX



While I don't have any sample to shoot you at the moment, the approach I used to do this is to create template form.
I created a form that has the common settings (fonts, colors, other propertysettings) that I consistently have to change, and I named it frmTemplate. Then I set that as the default form that Access uses when creating new form. Tools>Options>Forms/Reports tab

But since you want to select an existing form, this will require creating a form that displays the settings commonly changed , and pass in the name of a form, and hitr a GO button. Give a few hours and I could try to post one, unless some other Brainiac here already has one!


--------------------
"If I have seen further, then it is by standing on the shoulders of giants" - Sir Isaac Newton
Go to the top of the page
 
+
Aquadevel
post Feb 23 2012, 03:26 PM
Post #3

UtterAccess VIP
Posts: 6,902
From: Earth...



Hi RB,

The template would work dor new forms, But I have an existing db that I need to make a lot of changes to.

Thanks for any help!.. notworthy.gif


--------------------
Aqua

:cool: Sharing is caring :cool:
Go to the top of the page
 
+
Doug Steele
post Feb 23 2012, 03:30 PM
Post #4

UtterAccess VIP
Posts: 18,465
From: St. Catharines, ON (Canada)



Write a module to open each form in design view, change the desired properties and save the changes.


--------------------
Doug Steele, Microsoft Access MVP
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Technical Editor: Access 2010 Bible, published by Wiley, Access 2013 Bible, published by Wiley.
Go to the top of the page
 
+
pere_de_chipstic...
post Feb 23 2012, 03:59 PM
Post #5

UtterAccess Editor
Posts: 8,910
From: South coast, England



Hi Aqua

I go with Doug's suggestion, and have used this in the past to do the same:

CODE
Public Function UpdateAllFormsProp()
On Error GoTo err_proc

    Dim srcFrm As Object
    Dim strFrm As String
    
    For Each srcFrm In Application.CurrentProject.AllForms
        strFrm = srcFrm.Name
        DoCmd.OpenForm strFrm, acDesign
        Set srcFrm = Forms(strFrm)
        With srcFrm
            .SomeProperty1 = SomeValue1    
            .SomeProperty2 = SomeValue2
        End With
        DoCmd.Close acForm, strFrm, acSaveYes
    Next srcFrm

exit_proc:
    Exit Function
    
err_proc:
    MsgBox "Error in Function: 'UpdateAllFormProps'" & Chr(13) & Err.Description
    Resume exit_proc

End Function


Obviously changing
.SomeProperty1 = SomeValue1
.SomeProperty2 = SomeValue2
as appropriate

hth


--------------------
Warm regards
Bernie
Go to the top of the page
 
+
Aquadevel
post Feb 23 2012, 04:55 PM
Post #6

UtterAccess VIP
Posts: 6,902
From: Earth...



Hi Pere & Doug,

I agree I need to loop thru the forms. I ran Pere's code and have an 'Application Error".. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <

I run the following code:

CODE
[/code]
Public Sub UpdateForms()
On Error Resume Next

Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject

For Each obj In dbs.AllForms
DoCmd.OpenForm obj.Name, acDesign

'need property info here....:(

DoCmd.Close acForm, obj.Name, acSaveYes
Next obj
End Sub

[code]


It loops thru all forms, but no property change..

Loops drive me crazy.


--------------------
Aqua

:cool: Sharing is caring :cool:
Go to the top of the page
 
+
Doug Steele
post Feb 23 2012, 05:08 PM
Post #7

UtterAccess VIP
Posts: 18,465
From: St. Catharines, ON (Canada)



Look closer at Bernie's example. It's not enough to simply open the form: you have to instantiate it (his Set srcFrm = Forms(strFrm) statement), and then work with that instantiation.

And what have you put as the properties you want to change?

In general, using On Error Resume Next is a bad idea: it hides errors that you may need to correct.


--------------------
Doug Steele, Microsoft Access MVP
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Technical Editor: Access 2010 Bible, published by Wiley, Access 2013 Bible, published by Wiley.
Go to the top of the page
 
+
Aquadevel
post Feb 23 2012, 06:57 PM
Post #8

UtterAccess VIP
Posts: 6,902
From: Earth...



Doug,

Welp,

I've tried Pere's code again, still errors out with 'application error' pullhair.gif


--------------------
Aqua

:cool: Sharing is caring :cool:
Go to the top of the page
 
+
Doug Steele
post Feb 23 2012, 07:15 PM
Post #9

UtterAccess VIP
Posts: 18,465
From: St. Catharines, ON (Canada)



So what's the exact code you're using? And which line of the code raises the error?


--------------------
Doug Steele, Microsoft Access MVP
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Technical Editor: Access 2010 Bible, published by Wiley, Access 2013 Bible, published by Wiley.
Go to the top of the page
 
+
Aquadevel
post Feb 23 2012, 07:39 PM
Post #10

UtterAccess VIP
Posts: 6,902
From: Earth...



Doug,

CODE
[/code]

Public Function UpdateAllFormsProp()
On Error GoTo err_proc

    Dim srcFrm As Object
    Dim strFrm As String
    
    For Each srcFrm In Application.CurrentProject.AllForms
        strFrm = srcFrm.Name
        DoCmd.OpenForm strFrm, acDesign
        Set srcFrm = Forms(strFrm)
        With srcFrm
            .Close Button = "No"                  <<<<<<<<<~~~~~~  error's out here   with and without brackets
      
        End With
        DoCmd.Close acForm, strFrm, acSaveYes
    Next srcFrm

exit_proc:
    Exit Function
    
err_proc:
    MsgBox "Error in Function: 'UpdateAllFormProps'" & Chr(13) & Err.Description
    Resume exit_proc

End Function
[code]

Attached File(s)
Attached File  Capture.JPG ( 32.21K ) Number of downloads: 1
 


--------------------
Aqua

:cool: Sharing is caring :cool:
Go to the top of the page
 
+
Doug Steele
post Feb 23 2012, 08:15 PM
Post #11

UtterAccess VIP
Posts: 18,465
From: St. Catharines, ON (Canada)



Your syntax is incorrect.

CODE
        With srcFrm
            .CloseButton = False
        End With


For any property you're trying to change, put your cursor into the Property field, and press F1 to get into the Help file. That'll show you the proper way to refer to the property, and what are valid values for the property.


--------------------
Doug Steele, Microsoft Access MVP
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Technical Editor: Access 2010 Bible, published by Wiley, Access 2013 Bible, published by Wiley.
Go to the top of the page
 
+
Aquadevel
post Feb 23 2012, 08:19 PM
Post #12

UtterAccess VIP
Posts: 6,902
From: Earth...



Doug,


I've been up to long!!!!
you can 'slap me!!.. cheers.gif

Thanks!! uarulez2.gif


--------------------
Aqua

:cool: Sharing is caring :cool:
Go to the top of the page
 
+
pere_de_chipstic...
post Feb 24 2012, 03:21 AM
Post #13

UtterAccess Editor
Posts: 8,910
From: South coast, England



Aqua - glad you got it sorted, and Doug, thanks for following through on my post thumbup.gif (I'd taken an early night here!)

Looking through the code it may have been more robust to reference the instantiated form with it's own form variable,
i.e.
CODE

Public Function UpdateAllFormsProp()
On Error GoTo err_proc

Dim srcFrm As Object
Dim strFrm As String
Dim frmOpen As Form

For Each srcFrm In Application.CurrentProject.AllForms
strFrm = srcFrm.Name
Debug.Print strFrm
DoCmd.OpenForm strFrm, acDesign
Set frmOpen = Forms(strFrm)
With frmOpen
.AllowFormView = True
.AllowDatasheetView = False
.AllowPivotTableView = False
.AllowPivotChartView = False
.AllowLayoutView = False
End With
DoCmd.Close acForm, strFrm, acSaveYes
Next srcFrm

exit_proc:
Set frmOpen = Nothing
Set srcForm = Nothing
Exit Function

err_proc:
MsgBox "Error in Function: 'UpdateAllFormsProp'" & Chr(13) & Err.Description
Resume exit_proc

End Function
'
'


but as this is a bit of code that I only use occasionally and it works, I've never 'fixed' it!

Cheers


--------------------
Warm regards
Bernie
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 24th July 2014 - 02:18 PM