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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vartype() question 1

Status
Not open for further replies.

Kherozen

Programmer
Jun 5, 2003
129
CA
When i'm using Vartype in my form, it always return vbString(8)(except if the control is a date control where it return 7)

even when the control(a textbox ) contain only integers in fact it's impossible to be something else since it's bound to a table that allow only a integer in that field...
so how can i make it returning vbinteger(1) ?

it's a problem considering the fact that I need to know the type of the control to contruct a custom search (by looping throught the controls)



jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
and how do react SQL and the Money type ?
does it need "'" or "#" or anything else in front of it?




jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
hum apprently I need to do special treatment on money type controls as well any idea(s)?


jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
Anyone can help me with that one?


jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
Are you trying to use VarType on unbound controls? Those will always be 8, I think, unless you have the # date delimiters to tell Access to make it a Date.

If you're writing a search form using unbound controls, what really matters is the type of the corresponding field, and whether the data in the text box can be converted to the field's type. What I would do, I think, is use VarType on the corresponding field, then try to convert the text box data to that type using CSgn(), CDate(), CCurr(), CLng(), etc. You need an On Error statement to trap errors while you do this. If an error occurs, you know the user keyed something bad into the text box, and you know what type of data you needed. If no error occurs, then you know what type of data you have.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Thanks you


jul ^_^
"Computer Science is no more about computers than astronomy is about telescopes"
E. W. Dijkstra.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top