By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

How can we create an object (edit box, checkbox) at run time ??

overcomer
P: 25
Hi,

This is related to Code Behind AutoForm question that I've posted yesterdat but no one replies to that.

What i want a solution for is I need to have a flexible page1 whereas the field/objects (fields from a certain table that were added/created dynamically in a separate page2) could be created in the page1 at run time (using VB code). I'm using MS Access 2003 in Windows XP environment.

I've tried the Load funciton but it's not working as the object does not have an index property in MS Access.

Your comments/suggestions will be a big help.

Thanks.

Regards,
Cindy
Nov 4 '08 #1
Share this Question
Share on Google+
2 Replies


FishVal
Expert 2.5K+
P: 2,653
Hello, Cindy.

You may use CreateControl() method.
Keep in mind that form where control is being created has to be opened in design view and be not the form where CreateControl() method is being executed.
Below is a simple example.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  
  3.     Dim strName As String
  4.  
  5.     strName = "Form2"
  6.     DoCmd.OpenForm strName, acDesign
  7.     CreateControl strName, acTextBox, acDetail, , , 100, 100, 2000, 250
  8.     DoCmd.OpenForm strName, acNormal, , , , acWindowNormal
  9.  
  10. End Sub
  11.  
As an alternative you may design form with a sufficient fixed number of controls and change their visibility as required.

Regards,
Fish
Nov 4 '08 #2

overcomer
P: 25
Thank you so much Fish... it is really a big help...
Nov 4 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.