Field types

H

hughess7

Hi all

I am creating a search form, I have populated a combo box in the header with
the row source based on Field list from a query (aliases of real field
names). How can I add an extra column to this containing each fields data
types, so I can use this somehow in a filter in vba? I have a lot of fields
so I want to be able to use one text box as search criteria which can be used
to enter text, number or a date etc.

Thanks in advance for any help.
 
T

Tom van Stiphout

On Thu, 8 Oct 2009 04:43:01 -0700, hughess7

You'll need to switch the dropdown's RowSourceType to ValueList, and
populate it with data yourself. Something like this (off the top of my
head)
dim qd as dao.querydef
set qd=currentdb.querydefs("myQuery")
dim fld as dao.field
dim s as string
for each fld in qd.fields
s = s & fld.Name & ";" & GetDataType(fld.Type) & ";"
next
me.myDropDown.RowSource = s

function GetDataType(byval lngType as long) as string
dim s as string
select case lngType
case dbText
s = "Text"
case dbLong
s = "Long Integer"
'etc.
end select
end function


-Tom.
Microsoft Access MVP
 
T

Tom van Stiphout

Oops: need to add one line:
GetDataType = s
End Function

-Tom.
Microsoft Access MVP
 
H

hughess7

Thanks Tom worked a treat :). Now I just have to figure out how to use this
info to filter my subform records...

Cheers
Sue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top