Field Type Help

  • Thread starter Thread starter Vivista Eastbourne
  • Start date Start date
V

Vivista Eastbourne

Hi,

I have a listbox lst1 which contains field values of tbl1

I have txtsearch1 and txtsearch2 textboxes

How do I only enable txtsearch2 when the field data type chosen in lst1 is a
time/date type.

ie. if lst1 datatype = "date/Time" then txtsearch.visible = True

something like that

please help

Many Thanks

A
 
Vivista,
This is a bit odd... A listbox will always return the value of the first column. If
that listbox column contains text ("ABCD...") and is mixed with what look like dates
(01/01/06)... then those aren't really DateType... they are just text. A column can't
hold both Text and Date Types.

If your Text entries (other than the psuedo dates) have no "/" character in them, then
you could use the AfterUpdate event of Lst1 to determine if the text selected "looks like
a date."

Private Sub Lst1_AfterUpdate()
If InStr([Lst1],"/") <> 0 Then
TextSearch1.Enabled = False
TextSearch2.Enabled = True
Else
TextSearch1.Enabled = True
TextSearch2.Enabled = False
End If
End Sub
 
Hi Al,

Thanks for your response,
the listbox doesn't contain the record data, only the field name, what i
would like to know is, if the datatype of the selected field is text, only
show one textbox, if it is a date, show both textboxes, the idea bieing to
allow for a date range in the query which reads the textboxes.

i hope this makes sense, thanks

Andy (Visita Eastbourne)

Al Camp said:
Vivista,
This is a bit odd... A listbox will always return the value of the
first column. If that listbox column contains text ("ABCD...") and is
mixed with what look like dates (01/01/06)... then those aren't really
DateType... they are just text. A column can't hold both Text and Date
Types.

If your Text entries (other than the psuedo dates) have no "/" character
in them, then you could use the AfterUpdate event of Lst1 to determine if
the text selected "looks like a date."

Private Sub Lst1_AfterUpdate()
If InStr([Lst1],"/") <> 0 Then
TextSearch1.Enabled = False
TextSearch2.Enabled = True
Else
TextSearch1.Enabled = True
TextSearch2.Enabled = False
End If
End Sub

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


Vivista Eastbourne said:
Hi,

I have a listbox lst1 which contains field values of tbl1

I have txtsearch1 and txtsearch2 textboxes

How do I only enable txtsearch2 when the field data type chosen in lst1
is a
time/date type.

ie. if lst1 datatype = "date/Time" then txtsearch.visible = True

something like that

please help

Many Thanks

A
 
Andy,
the listbox doesn't contain the record data, only the field name,...
I'm afraid that doesn't make sense to me.
A listbox displays a list of values for the user to select from, similar to a combo
box. It has a query or table behind it that determines what values/choices are presented
to the user for selection.

What values does your listbox display... please give several examples. And, please
describe in detail how you want this "process" to work.

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

andy g said:
Hi Al,

Thanks for your response,
the listbox doesn't contain the record data, only the field name, what i would like to
know is, if the datatype of the selected field is text, only show one textbox, if it is
a date, show both textboxes, the idea bieing to allow for a date range in the query
which reads the textboxes.

i hope this makes sense, thanks

Andy (Visita Eastbourne)

Al Camp said:
Vivista,
This is a bit odd... A listbox will always return the value of the first column. If
that listbox column contains text ("ABCD...") and is mixed with what look like dates
(01/01/06)... then those aren't really DateType... they are just text. A column can't
hold both Text and Date Types.

If your Text entries (other than the psuedo dates) have no "/" character in them,
then you could use the AfterUpdate event of Lst1 to determine if the text selected
"looks like a date."

Private Sub Lst1_AfterUpdate()
If InStr([Lst1],"/") <> 0 Then
TextSearch1.Enabled = False
TextSearch2.Enabled = True
Else
TextSearch1.Enabled = True
TextSearch2.Enabled = False
End If
End Sub

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


Vivista Eastbourne said:
Hi,

I have a listbox lst1 which contains field values of tbl1

I have txtsearch1 and txtsearch2 textboxes

How do I only enable txtsearch2 when the field data type chosen in lst1 is a
time/date type.

ie. if lst1 datatype = "date/Time" then txtsearch.visible = True

something like that

please help

Many Thanks

A
 
Hi Al,

lst1
Row Source Type = Field List
Row Source = tbl1

If the datatype of the Field selected in lst1 = text, then only show
TextSearch1
If the datatype of the Field selected in lst1 = Date/Time, then show
TextSearch1 and TextSearch2

The idea is that a query is run, if the datatype is date/time the query uses
the date range with a between clause

Thanks

Andy


Al Camp said:
Andy,
the listbox doesn't contain the record data, only the field name,...
I'm afraid that doesn't make sense to me.
A listbox displays a list of values for the user to select from, similar to a combo
box. It has a query or table behind it that determines what values/choices are presented
to the user for selection.

What values does your listbox display... please give several examples. And, please
describe in detail how you want this "process" to work.

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

"andy g" <ajg> wrote in message news:[email protected]...
Hi Al,

Thanks for your response,
the listbox doesn't contain the record data, only the field name, what i would like to
know is, if the datatype of the selected field is text, only show one textbox, if it is
a date, show both textboxes, the idea bieing to allow for a date range in the query
which reads the textboxes.

i hope this makes sense, thanks

Andy (Visita Eastbourne)

Vivista,
This is a bit odd... A listbox will always return the value of the first column. If
that listbox column contains text ("ABCD...") and is mixed with what look like dates
(01/01/06)... then those aren't really DateType... they are just text. A column can't
hold both Text and Date Types.

If your Text entries (other than the psuedo dates) have no "/" character in them,
then you could use the AfterUpdate event of Lst1 to determine if the text selected
"looks like a date."

Private Sub Lst1_AfterUpdate()
If InStr([Lst1],"/") <> 0 Then
TextSearch1.Enabled = False
TextSearch2.Enabled = True
Else
TextSearch1.Enabled = True
TextSearch2.Enabled = False
End If
End Sub

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


Hi,

I have a listbox lst1 which contains field values of tbl1

I have txtsearch1 and txtsearch2 textboxes

How do I only enable txtsearch2 when the field data type chosen in lst1 is a
time/date type.

ie. if lst1 datatype = "date/Time" then txtsearch.visible = True

something like that

please help

Many Thanks

A
 
Vivista,
Row Source Type = Field List
That we should have known earlier! FieldList is rarely used...

Since your only choosing 1 of 2 options (Text or Date), the listbox is definitely bit
of overkill. You would need to interrogate the Table and determine the Field Type. Way
more complicated than it needs to be...

Just place an option group (optCriteriaType) on the form with 2 choices of Text Search
(=1) or Date Range Search (=2)

Then on the AfterUpdate of the Option Group optCriteriaType...
If optCriteriaType = 1 Then
Field1.Enabled = True
Field2.Enabled = False
ElseIf optCriteria = 2 Then
Field1.Enabled = True
Field2.Enabled = True
End If

BUT, your headed for real trouble. Your using the same field (Field1) to supply
either a Text criteria or a StartDate Criteria to your query. That would essentially
require two queries... one to handle Field1 as Text Criteria, and another to handle Field1
as a StartDate in a range.

Make Field1 a Text Criteria field, and create two separate fields (Field2 and Field3)
to handle Start and Stop Dates. Adjust the Enable/Disable code above to include Field3.

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions



Vivista Eastbourne said:
Hi Al,

lst1
Row Source Type = Field List
Row Source = tbl1

If the datatype of the Field selected in lst1 = text, then only show
TextSearch1
If the datatype of the Field selected in lst1 = Date/Time, then show
TextSearch1 and TextSearch2

The idea is that a query is run, if the datatype is date/time the query uses
the date range with a between clause

Thanks

Andy


Al Camp said:
Andy,
the listbox doesn't contain the record data, only the field name,...
I'm afraid that doesn't make sense to me.
A listbox displays a list of values for the user to select from, similar to a combo
box. It has a query or table behind it that determines what values/choices are presented
to the user for selection.

What values does your listbox display... please give several examples. And, please
describe in detail how you want this "process" to work.

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

"andy g" <ajg> wrote in message news:[email protected]...
Hi Al,

Thanks for your response,
the listbox doesn't contain the record data, only the field name, what i would like to
know is, if the datatype of the selected field is text, only show one textbox, if it is
a date, show both textboxes, the idea bieing to allow for a date range in the query
which reads the textboxes.

i hope this makes sense, thanks

Andy (Visita Eastbourne)

Vivista,
This is a bit odd... A listbox will always return the value of the first column. If
that listbox column contains text ("ABCD...") and is mixed with what look like dates
(01/01/06)... then those aren't really DateType... they are just text. A column can't
hold both Text and Date Types.

If your Text entries (other than the psuedo dates) have no "/" character in them,
then you could use the AfterUpdate event of Lst1 to determine if the text selected
"looks like a date."

Private Sub Lst1_AfterUpdate()
If InStr([Lst1],"/") <> 0 Then
TextSearch1.Enabled = False
TextSearch2.Enabled = True
Else
TextSearch1.Enabled = True
TextSearch2.Enabled = False
End If
End Sub

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions


Hi,

I have a listbox lst1 which contains field values of tbl1

I have txtsearch1 and txtsearch2 textboxes

How do I only enable txtsearch2 when the field data type chosen in lst1 is a
time/date type.

ie. if lst1 datatype = "date/Time" then txtsearch.visible = True

something like that

please help

Many Thanks

A
 
Back
Top