Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

change control type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jay - 31 May 2007 17:52 GMT
--------------------------------------------------------------------------------

I am using this code to change a text box into a combo box with VBA Code.

txtBox.ControlType = acComboBox

when I run it it says "to set this property, open the form in design view"
...which defeats the purpose of doing it in VBA.

any thoughts???
Ofer Cohen - 31 May 2007 18:10 GMT
Why do you want to change the field type?

Create a text box and a combo box, one on top of the other, and set the
visiblity of each one of then

Me.TextBox.Visible = (Condition)
Me.ComboBox.Visible = Not (Condition)

So it will alwys set one to visible True and the other to False
Signature

Good Luck
BS"D

> --------------------------------------------------------------------------------
>
[quoted text clipped - 6 lines]
>
> any thoughts???
Cheese_whiz - 31 May 2007 18:11 GMT
Hi Jay,

Why not just create two controls and show/hide them based on your needs?

CW

> --------------------------------------------------------------------------------
>
[quoted text clipped - 6 lines]
>
> any thoughts???
jay - 31 May 2007 18:20 GMT
that's what i currently have, which will work fine.  just was curious to see
if i had the code wrong.

> Hi Jay,
>
[quoted text clipped - 12 lines]
> >
> > any thoughts???
Cheese_whiz - 31 May 2007 18:39 GMT
Hi Jay,

What you appear to be attempting is actually changing the control type of a
SINGLE control back and forth depending on your needs.  What I'm suggesting
(as well as the poster above me) is that you just go ahead and make TWO
controls, one of each kind (one textbox, one combo box), stack them on top of
each other so they sit in the same place on your form, and use the 'visible'
property (of each of them) to hide one and show the other one depending on
what you need.

CW

> that's what i currently have, which will work fine.  just was curious to see
> if i had the code wrong.
[quoted text clipped - 15 lines]
> > >
> > > any thoughts???
UpRider - 31 May 2007 23:52 GMT
Jay, Here's an actual example of modifying a form via VBA in design mode:
   DoCmd.OpenForm "frmInputBox", acDesign
   Forms!frmInputbox!lstZip.RowSource = "SELECT Zip, City, St, ZipID FROM
tblZipcode " _
       & "WHERE tblZipcode.Zip=fcnZipArg(2);"
   DoCmd.Close acForm, "frmInputBox", acSaveYes
   DoCmd.OpenForm "frmInputBox"

HTH, UpRider

> --------------------------------------------------------------------------------
>
[quoted text clipped - 6 lines]
>
> any thoughts???
Douglas J. Steele - 01 Jun 2007 00:02 GMT
That's how to modify the RowSource. RowSource can be modified that way.

Jay's wanting to modify the ControlType of a control. That can't be done
unless the form is open in design mode. Of course, I can't see any reason
why you'd want to change it programmatically. If sometimes you need a text
box and sometimes a combo box, put both on the form, and only make one
visible at a time.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Jay, Here's an actual example of modifying a form via VBA in design mode:
>    DoCmd.OpenForm "frmInputBox", acDesign
[quoted text clipped - 17 lines]
>>
>> any thoughts???
UpRider - 01 Jun 2007 00:12 GMT
Doug, I believe my code does open the form in design mode.  He would
substitue his code for the rowsource code, which is only for example.
The steps are (all via VBA):

Open the form in design mode
Make the changes
Save the form with changes
Open the revised form

UpRider

> That's how to modify the RowSource. RowSource can be modified that way.
>
[quoted text clipped - 26 lines]
>>>
>>> any thoughts???
Douglas J. Steele - 01 Jun 2007 00:44 GMT
Sorry, you're right: it is opening in Design mode.

I still don't understand the requirement to change the control type
programmatically!

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Doug, I believe my code does open the form in design mode.  He would
> substitue his code for the rowsource code, which is only for example.
[quoted text clipped - 38 lines]
>>>>
>>>> any thoughts???
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.