My Assistant
![]()
Custom Search
|
![]() ![]() |
![]() |
![]() Post#1 | |
UtterAccess VIP Posts: 6,902 Joined: 8-August 05 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.... ![]() |
![]() Post#2 | |
![]() UtterAccess VIP Posts: 1,731 Joined: 28-March 03 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. Ocreated 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! |
![]() Post#3 | |
UtterAccess VIP Posts: 6,902 Joined: 8-August 05 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 |
![]() Post#4 | |
![]() UtterAccess VIP Posts: 21,673 Joined: 8-January 07 From: St. Catharines, ON (Canada) ![]() | Write a module to open each form in design view, change the desired properties and save the changes. |
![]() Post#5 | |
![]() UtterAccess Editor Posts: 10,196 Joined: 8-November 07 From: South coast, England ![]() | Hi Aqua 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 Has appropriate hth |
![]() Post#6 | |
UtterAccess VIP Posts: 6,902 Joined: 8-August 05 From: Earth... ![]() | Hi Pere & Doug, agree I need to loop thru the forms. I ran Pere's code and have an 'Application Error".. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. <;.. < Orun 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. |
![]() Post#7 | |
![]() UtterAccess VIP Posts: 21,673 Joined: 8-January 07 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. |
![]() Post#8 | |
UtterAccess VIP Posts: 6,902 Joined: 8-August 05 From: Earth... ![]() | Doug, elp, I've tried Pere's code again, still errors out with 'application error' ![]() |
![]() Post#9 | |
![]() UtterAccess VIP Posts: 21,673 Joined: 8-January 07 From: St. Catharines, ON (Canada) ![]() | So what's the exact code you're using? And which line of the code raises the error? |
![]() Post#10 | |
UtterAccess VIP Posts: 6,902 Joined: 8-August 05 From: Earth... ![]() | Doug, !--c1--> 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) |
![]() Post#11 | |
![]() UtterAccess VIP Posts: 21,673 Joined: 8-January 07 From: St. Catharines, ON (Canada) ![]() | Your syntax is incorrect. !--c1--> 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. |
![]() Post#12 | |
UtterAccess VIP Posts: 6,902 Joined: 8-August 05 From: Earth... ![]() | Doug, I've been up to long!!!! you can 'slap me!!.. Thanks! |
![]() Post#13 | |
![]() UtterAccess Editor Posts: 10,196 Joined: 8-November 07 From: South coast, England ![]() | Aqua - glad you got it sorted, and Doug, thanks for following through on my post f" style="vertical-align:middle" emoid=":thumbup:" border="0" alt="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 |
![]()
Custom Search
|
![]() | Search Top Lo-Fi | 25th April 2018 - 11:25 AM |