PC Review


Reply
Thread Tools Rate Thread

Change form control format in code

 
 
Ayo
Guest
Posts: n/a
 
      4th Jan 2008
I am trying to use this code to change the format of a combobox from Number
to Text:
Me.cmbProjectNumber.Format="Text"
but I am having a proplem doing this. I would like to know if the is a
better way to do this. Thank you.
 
Reply With Quote
 
 
 
 
Steve Schapel
Guest
Posts: n/a
 
      4th Jan 2008
Ayo,

You do not mention the nature of the problem. But "Text" is not one of
the valid options for the Format property of a combobox. I think you
probably need to do like this instead:
Me.cmbProjectNumber.Format=""

--
Steve Schapel, Microsoft Access MVP

Ayo wrote:
> I am trying to use this code to change the format of a combobox from Number
> to Text:
> Me.cmbProjectNumber.Format="Text"
> but I am having a proplem doing this. I would like to know if the is a
> better way to do this. Thank you.

 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      4th Jan 2008
I have a combobox with a label. When the label is "Project Number", the
values in the cmbbox are Numbers and when the label is "Site ID Number" the
values in the cmbbox are texts, alphanumeric.
What I want to be able to do is set the format of the combobox to text when
the label is "Site ID Number". Is this possible?
Thanks.

"Steve Schapel" wrote:

> Ayo,
>
> You do not mention the nature of the problem. But "Text" is not one of
> the valid options for the Format property of a combobox. I think you
> probably need to do like this instead:
> Me.cmbProjectNumber.Format=""
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Ayo wrote:
> > I am trying to use this code to change the format of a combobox from Number
> > to Text:
> > Me.cmbProjectNumber.Format="Text"
> > but I am having a proplem doing this. I would like to know if the is a
> > better way to do this. Thank you.

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      4th Jan 2008
Ayo,

I believe I have already suggested a solution. Did you try what I gave
you in my earlier reply? What happened?

--
Steve Schapel, Microsoft Access MVP

Ayo wrote:
> I have a combobox with a label. When the label is "Project Number", the
> values in the cmbbox are Numbers and when the label is "Site ID Number" the
> values in the cmbbox are texts, alphanumeric.
> What I want to be able to do is set the format of the combobox to text when
> the label is "Site ID Number". Is this possible?

 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      4th Jan 2008
I got the same error message. It said I was trying to input a ttext into a
number field or my nummber is to large for the field setting.

"Steve Schapel" wrote:

> Ayo,
>
> I believe I have already suggested a solution. Did you try what I gave
> you in my earlier reply? What happened?
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Ayo wrote:
> > I have a combobox with a label. When the label is "Project Number", the
> > values in the cmbbox are Numbers and when the label is "Site ID Number" the
> > values in the cmbbox are texts, alphanumeric.
> > What I want to be able to do is set the format of the combobox to text when
> > the label is "Site ID Number". Is this possible?

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      4th Jan 2008
Ayo,

Can you copy/paste the whole of the code here - I mean the code that is
producing the error. Maybe someone will be able to spot a clue as to
what is going wrong. Thanks.

--
Steve Schapel, Microsoft Access MVP

Ayo wrote:
> I got the same error message. It said I was trying to input a ttext into a
> number field or my nummber is to large for the field setting.

 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      4th Jan 2008
Here is the code:
Private Sub frmSelectLevel_Click()
Me.cmbProjectNumber.Enabled = True
Select Case Me.frmSelectLevel
Case 1
Me.lblCombobox.Caption = "Project Number:"
Me.cmbProjectNumber.RowSource = "SELECT DISTINCT [Project
Number] FROM [Inscope Table] ORDER BY [Project Number];"
Me.cmbProjectNumber = Null
Me.cmbProjectNumber.Requery

Me.cmbTaskNumber.RowSource = "SELECT DISTINCT [Task Number] FROM
[Inscope Table] ORDER BY [Task Number];"
Me.cmbTaskNumber = Null
Me.cmbTaskNumber.Requery
Case 2
Me.lblCombobox.Caption = "Site ID Number:"
Me.cmbProjectNumber.Format = ""
Me.cmbProjectNumber.RowSource = "SELECT DISTINCT [National Site
ID] FROM [Inscope Table] ORDER BY [National Site ID];"
Me.cmbProjectNumber = Null
Me.cmbProjectNumber.Requery

Me.cmbTaskNumber.RowSource = "SELECT DISTINCT [Task Number] FROM
[Inscope Table] ORDER BY [Task Number];"
Me.cmbTaskNumber = Null
Me.cmbTaskNumber.Requery
End Select
End Sub

"Steve Schapel" wrote:

> Ayo,
>
> Can you copy/paste the whole of the code here - I mean the code that is
> producing the error. Maybe someone will be able to spot a clue as to
> what is going wrong. Thanks.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Ayo wrote:
> > I got the same error message. It said I was trying to input a ttext into a
> > number field or my nummber is to large for the field setting.

>

 
Reply With Quote
 
Steve Schapel
Guest
Posts: n/a
 
      4th Jan 2008
Ayo,

Since you are explicitly setting the Format of the combobox for the "1"
case, you probably should also be setting it for the "2" case. I guess
it would be:
Me.cmbProjectNumber.Format = "General Number"

But is that when you get the error message, when you click the
frmSelectLevel? Or what is frmSelectLevel? If it is an Option Group,
it would be better to have this code on its After Update event rather
than the Click event.

Another option you might consider, instead of trying to toggle the
properties of a single combobox to serve 2 such different functions,
would be to make 2 separate comboboxes, and then your code on the
frmSelectLevel would simply toggle their Visible property.

--
Steve Schapel, Microsoft Access MVP

Ayo wrote:
> Here is the code:

 
Reply With Quote
 
Ayo
Guest
Posts: n/a
 
      4th Jan 2008
Thanks for all the help Steve.

"Steve Schapel" wrote:

> Ayo,
>
> Since you are explicitly setting the Format of the combobox for the "1"
> case, you probably should also be setting it for the "2" case. I guess
> it would be:
> Me.cmbProjectNumber.Format = "General Number"
>
> But is that when you get the error message, when you click the
> frmSelectLevel? Or what is frmSelectLevel? If it is an Option Group,
> it would be better to have this code on its After Update event rather
> than the Click event.
>
> Another option you might consider, instead of trying to toggle the
> properties of a single combobox to serve 2 such different functions,
> would be to make 2 separate comboboxes, and then your code on the
> frmSelectLevel would simply toggle their Visible property.
>
> --
> Steve Schapel, Microsoft Access MVP
>
> Ayo wrote:
> > Here is the code:

>

 
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
VBA Code to Change Currency Format Jim Microsoft Excel Programming 7 31st Jul 2009 06:47 AM
How can I set the format of a control in code Ayo Microsoft Access 5 17th Dec 2007 07:12 PM
How do I change a report label control from a form code modual? =?Utf-8?B?Q0pfREI=?= Microsoft Access VBA Modules 5 9th Jun 2006 02:56 AM
Change Form Control text on User Control Steven K Microsoft ASP .NET 1 19th Aug 2004 07:55 AM
Change Format of a Control Rhonda Floyd Microsoft Access Form Coding 2 19th Sep 2003 01:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:35 PM.