Is this code correct?

A

Ayo

Me!ProjectNumber.Format = "Text"

Can I use something like this to change a combobox's format from number to
text. My problem is I get an error message in the combobox telling me that I
am trying to enter a text in a numeric field. I figured if I change the
object's format right before I make the selection, than thevalue in the field
will will be recognized as a text data type.
Thanks
 
A

Al Campagna

Ayo,
The Format of a numeric field only applies to how a number is displayed,
and has no effect on the actual value.
You can not enter text into a numeric field. If you must... then the
field should be defined as text in your table design.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
A

Ayo

Let me see if I can explain the situation better. I have a form with 2 ption
buttons and one combobox. The choice of the option button determines what is
avaliable for selection in the combobox.
If the user selects the project option button, the combobox have avaliable
project numbers, which are strictly number. If the user selects the Site
option button, the combobox have avaliable site numbers, which are
combination of numbers and letters, alphanumeric (or text).
When the form opens and I select the Site option first, everything works ok.
That means no errors to hang-ups, nothing. But if I select the project option
first, the is no problem when I make a selection in the combobox. The problem
and erroe arises whan I try to change my selection.
Lets say for instance I made a mistake by selecting the project option
button, or I changed my mind and decided that I wanted to run the site
option. If I now select the site option,after selecting the project option
and selected a project number in the combobox. If i now select the site
option and try o select the site ID number in the combobox, this is when I
get the error message and the program grid to an halt.
This is why I was hoping I could find a fix or a better way around this
problem that doesn't involve creating 2 comboboxes for either option.
 
R

rquintal

Let me see if I can explain the situation better. I have a form with 2 ption
buttons and one combobox. The choice of the option button determines what is
avaliable for selection in the combobox.
If the user selects the project option button, the combobox have avaliable
project numbers, which are strictly number. If the user selects the Site
option button, the combobox have avaliable site numbers, which are
combination of numbers and letters, alphanumeric (or text).
When the form opens and I select the Site option first, everything works ok.
That means no errors to hang-ups, nothing. But if I select the project option
first, the is no problem when I make a selection in the combobox. The problem
and erroe arises whan I try to change my selection.
Lets say for instance I made a mistake by selecting the project option
button, or I changed my mind and decided that I wanted to run the site
option. If I now select the site option,after selecting the project option
and selected a project number in the combobox. If i now select the site
option and try o select the site ID number in the combobox, this is when I
get the error message and the program grid to an halt.
This is why I was hoping I could find a fix or a better way around this
problem that doesn't involve creating 2 comboboxes for either option.







- Show quoted text -

Trying to Hide the problem by using a Format Statement instead of
fixing the code for the Combobox AfterUpdate event is not going to
help. Something in the Option Group's code is not working correctly,
please post it so we can together figure out what needs to be changed.

Q
 
S

Steve Schapel

Ayo,

No. As I have recently advised you elsewhere, this is not correct.

If you look at the drop-down list of possible entries for the Format
property of the combobox, you will see the pre-defined options
available. "Text" is not one of them.

As I advised you before, you could put like this:
Me!ProjectNumber.Format = ""

As I advised you before, in such a situation, I personally would use two
comboboxes, over the top of each other, and toggle their Visible
property, so that you see the one you want in response to the selection
in the Option Group. This will be easier.

We are assuming that the combobox is unbound.
 
P

Pat Hartman

It sounds like Access is making an assumption as to the data type of the
combo control based on the first selection. You may be able to get around
this by changing the RowSource query for the Project. Try the cStr()
function to convert the Project Number to a string.

Select cStr(ProjectNumber) as strProjectNumber From YourTable Order by
ProjectNumber;
 
Top