Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data type mismatch help

Status
Not open for further replies.

lashwarj

IS-IT--Management
Nov 1, 2000
1,067
0
0
US
I have a list box with a bound colum that when you click sets a value in a textbox.... The info set correct but then when I go to use the value it generates a Data Type Mismatch.


The field I am trying to set it to is a interger value and in the debugger shows the value as being "487" and the value to replace it as "486 ". I tried a trim on it but that doesnt do anything.
 
P.S. Value that is generating the datatype missmatch is coming from a cursor dump
 
It looks like you are trying to place a Character String in an Integer, hence the data type mismatch.

You need to convert the Character value to a numeric value.

x = "486 " && char value stored in x
?TYPE("x")
SET DECI TO 0 && INT would work as well - no zero decimals
y = VALU(X) && or....
?y
?TYPE("y")
y = INT(VALU(X))
?y

Look at the TYPE command in the help file. It is useful in determining what type of data (char/numeric) etc, that a variable is.

Some people myself included, use what is called "Hungarian Notation", to track the TYPE of variables they are working with. You might want to get in the habit of naming variables with the first letter of what they are...
ie... cTextBox1 = Character Type
nTextBox1 = Numberic Type
yTextBox1 = Currency Type
mTextBox1 = Memo Type
There are more, the rest escape me right now, but you get the idea.

HTH - Wayne
 
Ok this looks great but I have no clue what your doing, I havent tried it in my code yet. Here is what I am looking at on my end

Thisform.bldg_id.value = Thisform.location_info.Value

simple as that, I need to get the Thisform.bldg_id.Value to change the format...I mean is it as easy as this


x = Thisform.bldg_id.value
?TYPE("x")
SET DECI TO 0
y = VALU(X)
?TYPE("y")
y = INT(VALU(X))
?y
 
And where would i place that, would it be right after the command button statement that sets the value

EX in my code would i put that right after the
Thisform.bldg_id.Value = Thisform.location_info.value
 
After trying it in my code it gives me a valu.prg not found, so it is looking for a program file where you are delcaring the y value
 
and then how do I refrence the converted value, would i still refrence it as
Thisform.bldg_id.value = Thisform.location_info.value

or would it be
Thisform.bldg.value = x


I dont know how you are doing it so I am sorry but I need details
 
lashwarj:

Even though the documentation say the listbox can have character, integer, or numeric data, only character data is actually stored in the listbox. (The listbox is numeric and integer friendly and converts it automatically when bound to an array or table field.)

When you store values programmactically, you need to store it as character data then convert it for your particular purposes when you take it out.

Darrell 'We all must do the hard bits so when we get bit we know where to bite' :)
 
That sounds great and I appreciate the tip but how would i do that.
 
I mean here we go........ I am running a select that may return more then one value and I want it to show in a listbox or a combobox. I then need for the user to select which one they want and then have the value used to update later in my code


What would you recommend ?
 
lashwarj:

Try intVariable = int(val(listbox.value)).

Darrell 'We all must do the hard bits so when we get bit we know where to bite' :)
 
Where ? And with what ?

I am dumb to this method so i need more detail, sorry.
 
Should that be

intVariable = int(val(thisform.location_info.value))
Thisform.bldg_id.value = intvariable
 
I dumb about your question. What exactly do you want to know?

Darrell 'We all must do the hard bits so when we get bit we know where to bite' :)
 
Posted to slow. Yes to your last post.

Yes to...

intVariable = int(val(thisform.location_info.value))
Thisform.bldg_id.value = intvariable

I assume location_info is the listbox.

Darrell 'We all must do the hard bits so when we get bit we know where to bite' :)
 
ok you guys were so helpful lets see if i can fix my last issue. I am running the results of the list box from a cursor dump, when the form loads it tells me the cursor value is not present , how do I make it so it doesnt give me this error..
I mean can I hardcode it, set it so its a simple list box with no rowsource then in the command button events place

Thisform.location_info.rowsource = Templocation.formated_address, bldg_id

Would this work
 
lashwarj

I have trouble following your thread. You have made 12 entries in this thread, most of them you are not really asking a question, but mostly informaing us of you progress. It would be easier if you would start your thread with a specific question, and wait for an answer from us. It looks like a one-way conversation. Mike Gagnon
 
Sorry Mike it was more of a I posted an error then solved the one error then discovered another, and then the last entry was not a suggestion or a solution it was more or less just pointing out something that did not need to be pointed out due to the fact that the only post made by the last entry user was a critisism not a suggestion or solution. It did not seem to bother the people who were productively helping. You have in the past been very helpful and I am sorry for this post but if you were so concerned with the entry amounts why did you feel it was necessary to make your post when it was not helpful or productive.
 
lashwarj

This thread is a continuation of thread184-356582 and thread184-356726 is also a continuation of thread184-356582.

You seem to forget that members give of their valuable time and expertise without charge.

You have started 190 threads in this forum, but only ever voted 8 posts as being helpful - that to me indicates that something is off balance.

If you, lashwarj, don't get the answer you need within your timeframe, you seem to be of the opinion that if you start a new thread, then members will respond quicker to the new thread than they would have done to the existing thread.

The published reasons for red flagging a post are 'off-topic, duplicates, flames, illegal, vulgar, or students posting their homework'.

Other reasons supported by the Tek-Tips management include 'time wasting'

All members have the right, and should exercise it whever appropriate, to red flag threads/posts they consider improper.

The Tek-Tips management will be very supportive of any legitimate red flags.

IMHO, Mike comments are entirely appropriate - you are wasting people's valuable time with your commenting and the starting of new threads without waiting for the existing ones to come to a conclusion.

This post to make you aware of the consequences of continuing with your current approach - you may well be red flagged and the thread/post removed, and you are also risking your membership of Tek-Tips as well.

HTH

Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top