?
Solved

CreateControl using Access 2000

Posted on 2003-03-18
9
Medium Priority
?
1,567 Views
Last Modified: 2007-12-19
Hi.. i want to make a form in access 2000 which contains textboxes.. how can i create the textboxes using vba in runtime?


Private Sub Form_Load()

Dim newControl As Control
DoCmd.OpenForm "Form1", acDesign, , , , acHidden
Set newControl = CreateControl("Form1", acTextBox, , , , 100, 100, 1000, 1000)

DoCmd.RepaintObject acForm, "Form1"
DoCmd.Save acForm, "Form1"

End Sub


I can't find what mistake i made in that program.. Everytime i want to open Form1, there always be a Message Box:
Run-time error '2174':
You can't switch to a different view at this time.

Can somebody help me? Thanks :):)
0
Comment
Question by:pipinana02
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8165665
Which line do you get the error on ?
0
 

Author Comment

by:pipinana02
ID: 8171161
Hi.. hehehe.. sorry forget to mention.. i always get the error on line:

DoCmd.OpenForm "Form1", acDesign, , , , acHidden

Hehehe.. Hopefully u can help me.. :)
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 225 total points
ID: 8171222
Is Form1 the form that the above code is in ? If so, you can't do this - you can't switch the form into design view from code in the form itself. You'll have to do it from another form.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:pipinana02
ID: 8171251
Hi.. hehehe.. sorry forget to mention.. i always get the error on line:

DoCmd.OpenForm "Form1", acDesign, , , , acHidden

Hehehe.. Hopefully u can help me.. :)
0
 

Author Comment

by:pipinana02
ID: 8171256
Yes.. Form 1 is the form where the above code is in..

So, you mean i have to create another form that create Form1 is it? Can you give me example bcoz i'm a bit confused.. hehehe.. thankss :)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8171270
Basically, you just put the code you've already got above into say, a command button on another form. It will then be able to open Form1 in design view without a problem.
0
 

Author Comment

by:pipinana02
ID: 8171323
hehehe it works well.. thanks :)

but if i change to:
DoCmd.OpenForm "Form2", acDesign, , , , acWindowsNormal

the user will view Form2 in Design mode.. how to make the user only see it in Form View? Thanks again :)
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 8171336
I'm not sure I understand - can you not open it with acHidden as you did before ?

If you just want Form2 to open normally, simply use:
DoCmd.OpenForm "Form2"
0
 

Author Comment

by:pipinana02
ID: 8171350
oh.. okkk.. thanks soo much for helping me out :) hehehe i'm new to ms access.. so i'm not really familiar with it.. hehehe.. thankss :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question