开发者

Microsoft Access 2000 Switch Views at Runtime

开发者 https://www.devze.com 2023-03-18 16:48 出处:网络
I\'m creating a form programatically that has a ComboBox that is populated with a list of options.On selecting an option, I\'d like the form to be populated with various controls.

I'm creating a form programatically that has a ComboBox that is populated with a list of options. On selecting an option, I'd like the form to be populated with various controls.

At the moment I'm achieving it by:

FormName = Screen.ActiveForm.Name
DoCmd.Close acForm, FormName, acSaveYes
DoCmd.OpenForm FormName, acDesign
' Do Work to create controls
DoCmd.Close acForm, FormName, acSaveYes
DoCmd.OpenForm FormName, acNormal

The problem is, I'm going to have many temporary forms saved in my database. So as I see it there are two options for me,

  1. Switch to design view without having to save the form
  2. Be able to delete the form when I'm done with it

I've tried putting

DoCmd.DeleteObject acForm, FormName

in 开发者_StackOverflow社区the OnClose, and OnUnload triggers, but it results in a "You can't delete the object 'Form1' while it is open" error

Any suggestions?


Do your options result in a limited number of controls on the form? In other words, would it be possible to have all the controls you need created ahead of time, just not Visible? Then all you would need to do is show and position what is needed without having to re-create everything from scratch.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号