CInt and table

belsha

Registered User.
Local time
Today, 02:18
Joined
Jul 5, 2002
Messages
115
I have a table with imported text fields that need to be changed to number fields. I used the CInt function in an update query to change "Male" into 0. Question is, in the table design view, the field still reads as type text. I will need to do calculations on these numbers, can you tell me the best way to do this?
 
Create an integer fld in your table and update it with cint(). Or else you can you cint() anytime you need to do a calc...

Ken
 
Maybe I am going about this the wrong way. I have a table that has data mostly in text format. I do a make table query from that data and create a table in a new database that still has that data as text. I run an update query to change, for instance, "Male" to 0 and then use the CInt function. Then I have to go into the table and change the field format to Integer? This is going to be done every month so there must be an easier way of doing all these steps?
 
Can you just append data in the table, using cint() to make the text a number before it gets to the new table?

Ken
 
Why would you need to run a make table query every month?
That doesn't make sense...

Simply see to it you've got your table in your "new" database up and ready having datatype numeric for your gender column.
Do not run an UPDATE query, simply use an INSERT statement.
And decode Male into 0.

RV
 
And don't double post in future, it's not really appreciated....

RV
 
Ken,
That would be OK if the information was already in 0,1 format and I just needed to change it to numeric then append it to a table where the field would be numeric, but I have to convert the Male to 0 before I append it, and NOT do that to the table it's coming from, just in the query.
RV - these are huge tables we are sending off to somewhere else in chunks, so we just want to do temporary tables for that month or quarter, then destroy them. There is another database where that segment of data and much more permanantly resides.
 
Then use the IIF function to convert Male into 0 (zero).
As for any calculations, use the CInt funktion to convert your 0's to numeric.

RV
 
This is kind of getting out of hand...

Let's see if I have this correct:

1. You have a table you import every month.
2. The table has a text fld named 'Gender'.
3. You need to count how many of each gender you have.

Is this correct? If this is the only issue you have with the way the table is set up, I see no reason to convert a fld...

a. Am I assuming correctly that in a report you list these records and then at the bottom you need to say something like:

Total Males: 125
Total Females: 136

???
Ken
 
No. I have a table with many fields that are text. Through a make table query I am taking the fields I need and exporting them into a new database. This new database will be created each month, the information sent to someone else, then destroyed. The someone else needs the information for many fields in numeric form, such as Male=0 for their purposes. They cannot use it in text form. SO,
In DB 1, I have a field called Gender that has "Male" or "Female"
In DB 2 a make table query creates a table with the Gender field, which then shows "Male" or "Female" from DB 1.
What I need is in DB2 Gender to be integer, 1 or 2.
Need the most efficient way to do that. I do not want to change the data in the DB1 table to 0,1 though, I want that to stay "Male" or "Female"
 
Referring to my former reply.

If you really DO need to change the datatype of your Gender column, you can't do this within your make table query, simple at that.
So the option is manually changing the datatype or using an ALTER TABLE statement to change it.

RV
 
RV -
Is there somewhere in my query statement below that I could use the CInt function and then append it into a premade table where that field would be formatted to integer?

Gender: IIf([Gender]="Male",0,1)
 
CInt(IIf([Gender]="Male",0,1))

RV
 
Darn, guess I was overlooking the obvious. Sorry to be a pain. Glad you got it to work. :)

Ken
 

Users who are viewing this thread

Back
Top Bottom