?
Solved

CreateControl using Access 2000

Posted on 2003-03-18
9
Medium Priority
?
1,592 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
  • 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
Technology Partners: 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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

615 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