I have a list which is populated with Fields from a table, I want to be able to determine if the data type of the value selected in the list is Number. Any ideas, i thought there would be something along the lines of
Me!lstQueryCriteria.Datatype, but my results turned up no dice.
The reason I wish to do this is, because I am creating a query in VBA and in the Where clause I use IN, and it is giving me a datatype mismatch whenever it is sent a Number data type.
The SQL statement created produces something along the lines of
IN('R10001','R10003')
But for a Number datatype
IN('1','3')
doesnot work, i need to remove the ' for this datatype
IN(1,3) and then it works
Excuse the babble, i think i have re-explained myself at least twice over.
3 36928 ADezii 8,834
Recognized Expert Expert
I have a list which is populated with Fields from a table, I want to be able to determine if the data type of the value selected in the list is Number. Any ideas, i thought there would be something along the lines of
Me!lstQueryCriteria.Datatype, but my results turned up no dice.
The reason I wish to do this is, because I am creating a query in VBA and in the Where clause I use IN, and it is giving me a datatype mismatch whenever it is sent a Number data type.
The SQL statement created produces something along the lines of
IN('R10001','R10003')
But for a Number datatype
IN('1','3')
doesnot work, i need to remove the ' for this datatype
IN(1,3) and then it works
Excuse the babble, i think i have re-explained myself at least twice over.
Here is a little Routine that will number all the Fields in a Table, list their Name, and if it is Numeric, list the Data Type. If not, N/A. Ideally, this could be refined and contained within a Function/Sub Procedure. You can adapt it to your own specifc needs, but if you further help just ask. The important point here is that the Type Property of a Field Object returns a Numeric Value indicating its Data Type. - Dim intNumberofFields As Integer, intFieldType As Integer, strTypeName As String
-
-
Dim fld As Field, intCounter As Integer, strFieldName As String
-
-
intNumberofFields = CurrentDb.TableDefs("tblEmployee").Fields.Count
-
-
For intCounter = 0 To intNumberofFields - 1
-
strFieldName = CurrentDb.TableDefs("tblEmployee").Fields(intCounter).Name
-
intFieldType = CurrentDb.TableDefs("tblEmployee").Fields(intCounter).Type
-
Select Case intFieldType
-
Case 2 'Byte
-
strTypeName = "Byte"
-
Case 3 'Integer
-
strTypeName = "Integer"
-
Case 4 'Long
-
strTypeName = "Long"
-
Case 6 'Single
-
strTypeName = "Single"
-
Case 7 'Double
-
strTypeName = "Double"
-
Case Else 'Not a Number
-
strTypeName = "N/A"
-
End Select
-
Debug.Print Format(intCounter + 1, "00") & ") " & strFieldName & " - " & strTypeName
-
Next intCounter
Sample Output:
01) Counter - Long
02) PayrollNumber - Long
03) Order Date - N/A
04) Required_Date - N/A
05) Received_Date - N/A
06) Rank - N/A
07) LastName - N/A
08) FirstName - N/A
09) MI - N/A
10) Designation - N/A
11) MiscCode - N/A
12) Company - N/A
13) Platoon - N/A
14) VacationCode - N/A
15) Title - N/A
16) Address - N/A
17) ZipCode - N/A
18) Sex - N/A
19) BloodType - N/A
20) PhoneNumber - N/A
21) BirthDate - N/A
22) AppointmentDate - N/A
23) AssignmentDate - N/A
24) LongevityDate - N/A
25) Badge - N/A
26) SSN - N/A
27) DriverLicenseNumber - N/A
28) DriverLicExpDate - N/A
29) TransferredOut - N/A
30) Backup - N/A
31) FullName - N/A
32) Years - Integer
33) L - N/A
34) NoDays - Long
35) InvDate - N/A
36) EndDate - N/A
37) SSAN - N/A
38) Date - N/A
39) Integer - Integer
40) Long - Long
41) Single - Single
42) Double - Double
43) Byte - Byte
Thanks for that, very helpful
ADezii 8,834
Recognized Expert Expert
Thanks for that, very helpful
No Problemo.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Josh |
last post by:
Hi,
I am trying to write a function in a module in MS Access 2000 that
will change the data type of a field called 'Start' in table
'bo_cpm_CS01ALL'. Here is the code that I have done so far...
|
by: sleepyant |
last post by:
Hi, how can I check the field data type of a column in a Dataset table? Like
whether it is a DateTime, a Binary or Character.
Please help. Thanks.
|
by: chellappa |
last post by:
Hi All,
How to find the data type of the variable ? is there any libaray
function avaiable? Because i want create generic data type of some
operation .
Thanks All
By
Chellappa
|
by: comteck |
last post by:
From one database, I am trying to create a table in a different database. Here is my code:
Dim dbDeja As DAO.Database
Dim tblEmployees As DAO.TableDef
Dim fldEmployeeNumber As Field
...
|
by: comteck |
last post by:
From one database, I am trying to create a table in a different database. Here is my code:
Dim dbDeja As DAO.Database
Dim tblEmployees As DAO.TableDef
Dim fldEmployeeNumber As Field
' Open...
| |
by: balaki |
last post by:
Hi All,
I am using VB.Net 2003 and Ms-Access 2003. I want to change the data type of fileds programmatically. I could not find any method in vb.net to do this.
i) I tried using the sql query...
|
by: fniles |
last post by:
I am using VB.NET 2005 and SQLDataReader.
How can I check the data type of a field in the DataReader ? Thank you.
Dim cmdSQL As SqlClient.SqlCommand
Dim drSQL As SqlClient.SqlDataReader
sSQL...
|
by: RN |
last post by:
Hi everyone,
First please let me explain. I am attempting to store pdf files in an MS
Access DB (2000) and I have written a subroutine to do this. My code seems
to work perfectly (see code...
|
by: Shashi Sadasivan |
last post by:
Hi,
i wanted to make a generec fntions which will compare a given object type against a lit of objects.
my list of object are a set of forms, but sor simplicity lets assume it to be a lit of int,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |