My Assistant
![]() ![]() |
|
|
Feb 23 2012, 02:43 PM
Post
#1
|
|
|
UtterAccess VIP Posts: 6,898 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.... (IMG:style_emoticons/default/iconfused.gif) |
|
|
|
Feb 23 2012, 02:56 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 1,730 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! |
|
|
|
Feb 23 2012, 03:26 PM
Post
#3
|
|
|
UtterAccess VIP Posts: 6,898 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!.. (IMG:style_emoticons/default/notworthy.gif) |
|
|
|
Feb 23 2012, 03:30 PM
Post
#4
|
|
|
UtterAccess VIP Posts: 17,635 From: Don Mills, ON (Canada) |
Write a module to open each form in design view, change the desired properties and save the changes.
|
|
|
|
Feb 23 2012, 03:59 PM
Post
#5
|
|
|
UtterAccess VIP Posts: 7,588 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 This post has been edited by pere_de_chipstick: Feb 23 2012, 04:01 PM |
|
|
|
Feb 23 2012, 04:55 PM
Post
#6
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Hi Pere & Doug, I agree I need to loop thru the forms. I ran Pere's code and have an 'Application Error".. (IMG:style_emoticons/default/confused.gif) 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. |
|
|
|
Feb 23 2012, 05:08 PM
Post
#7
|
|
|
UtterAccess VIP Posts: 17,635 From: Don Mills, 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. |
|
|
|
Feb 23 2012, 06:57 PM
Post
#8
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Doug, Welp, I've tried Pere's code again, still errors out with 'application error' (IMG:style_emoticons/default/pullhair.gif) |
|
|
|
Feb 23 2012, 07:15 PM
Post
#9
|
|
|
UtterAccess VIP Posts: 17,635 From: Don Mills, ON (Canada) |
So what's the exact code you're using? And which line of the code raises the error?
|
|
|
|
Feb 23 2012, 07:39 PM
Post
#10
|
|
|
UtterAccess VIP Posts: 6,898 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)
|
|
|
|
Feb 23 2012, 08:15 PM
Post
#11
|
|
|
UtterAccess VIP Posts: 17,635 From: Don Mills, 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. |
|
|
|
Feb 23 2012, 08:19 PM
Post
#12
|
|
|
UtterAccess VIP Posts: 6,898 From: Earth... |
Doug, I've been up to long!!!! you can 'slap me!!.. (IMG:style_emoticons/default/cheers.gif) Thanks!! (IMG:style_emoticons/default/uarulez2.gif) |
|
|
|
Feb 24 2012, 03:21 AM
Post
#13
|
|
|
UtterAccess VIP Posts: 7,588 From: South coast, England |
Aqua - glad you got it sorted, and Doug, thanks for following through on my post (IMG:style_emoticons/default/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 |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 21st May 2013 - 07:43 PM |