PC Review


Reply
Thread Tools Rate Thread

change control type

 
 
=?Utf-8?B?amF5?=
Guest
Posts: n/a
 
      31st May 2007
--------------------------------------------------------------------------------

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???
 
Reply With Quote
 
 
 
 
=?Utf-8?B?T2ZlciBDb2hlbg==?=
Guest
Posts: n/a
 
      31st May 2007
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
--
Good Luck
BS"D


"jay" wrote:

> --------------------------------------------------------------------------------
>
> 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???

 
Reply With Quote
 
=?Utf-8?B?Q2hlZXNlX3doaXo=?=
Guest
Posts: n/a
 
      31st May 2007
Hi Jay,

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

CW

"jay" wrote:

> --------------------------------------------------------------------------------
>
> 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???

 
Reply With Quote
 
=?Utf-8?B?amF5?=
Guest
Posts: n/a
 
      31st May 2007
that's what i currently have, which will work fine. just was curious to see
if i had the code wrong.

"Cheese_whiz" wrote:

> Hi Jay,
>
> Why not just create two controls and show/hide them based on your needs?
>
> CW
>
> "jay" wrote:
>
> > --------------------------------------------------------------------------------
> >
> > 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???

 
Reply With Quote
 
=?Utf-8?B?Q2hlZXNlX3doaXo=?=
Guest
Posts: n/a
 
      31st May 2007
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

"jay" wrote:

> that's what i currently have, which will work fine. just was curious to see
> if i had the code wrong.
>
> "Cheese_whiz" wrote:
>
> > Hi Jay,
> >
> > Why not just create two controls and show/hide them based on your needs?
> >
> > CW
> >
> > "jay" wrote:
> >
> > > --------------------------------------------------------------------------------
> > >
> > > 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???

 
Reply With Quote
 
UpRider
Guest
Posts: n/a
 
      31st May 2007
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

"jay" <(E-Mail Removed)> wrote in message
news:CB0C6C0B-5E6E-41FC-BA86-(E-Mail Removed)...
> --------------------------------------------------------------------------------
>
> 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???



 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      1st Jun 2007
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.

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


"UpRider" <(E-Mail Removed)> wrote in message
news:OMB$(E-Mail Removed)...
> 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
>
> "jay" <(E-Mail Removed)> wrote in message
> news:CB0C6C0B-5E6E-41FC-BA86-(E-Mail Removed)...
>> --------------------------------------------------------------------------------
>>
>> 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???

>
>



 
Reply With Quote
 
UpRider
Guest
Posts: n/a
 
      1st Jun 2007
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

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:%(E-Mail Removed)...
> 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.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "UpRider" <(E-Mail Removed)> wrote in message
> news:OMB$(E-Mail Removed)...
>> 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
>>
>> "jay" <(E-Mail Removed)> wrote in message
>> news:CB0C6C0B-5E6E-41FC-BA86-(E-Mail Removed)...
>>> --------------------------------------------------------------------------------
>>>
>>> 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???

>>
>>

>
>



 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      1st Jun 2007
Sorry, you're right: it is opening in Design mode.

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

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


"UpRider" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
> news:%(E-Mail Removed)...
>> 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.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "UpRider" <(E-Mail Removed)> wrote in message
>> news:OMB$(E-Mail Removed)...
>>> 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
>>>
>>> "jay" <(E-Mail Removed)> wrote in message
>>> news:CB0C6C0B-5E6E-41FC-BA86-(E-Mail Removed)...
>>>> --------------------------------------------------------------------------------
>>>>
>>>> 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???
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change control type =?Utf-8?B?am9obmI=?= Microsoft Access VBA Modules 3 20th Jul 2007 12:27 PM
Change control type at runtime RSH Microsoft ASP .NET 3 11th Jan 2007 05:45 PM
Change control type in VBA? =?Utf-8?B?cmczMg==?= Microsoft Access Form Coding 2 17th Jun 2005 03:13 PM
User Control codebehind type not compatible with ASP type? =?Utf-8?B?TSBL?= Microsoft ASP .NET 0 22nd Nov 2004 09:39 PM
The base class includes the field but its type is not compatible with the type of control. Daniel Melo Microsoft ASP .NET 0 8th Jan 2004 08:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:47 PM.