Unbound Text Control problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What I'm trying to do seems simple, but I can't get it to work. I've got a
form that builds a SQL statement for a pass-through query as the user selects
criteria on the form. One of the criteria is a date range. I want the "end
date" to default to the last_update_date in the underlying Oracle database.
I've got a query that retrieves this date and stores it in a local Access
table called tblDate.

So how do I get this date to appear on my form in the text control called
txtEndDate? I tried using tblDate as the record source for the form. This
works, but if the user changes the date, then that date is stored in the
table. I simply want to display the date contained in the table, and allow
the user to change it, if they wish, without having the date actually change
in tblDate.
 
Hi Kirk,

Instead of binding the textbox to the table, use the form's onload or
oncurrent even to fill in the text box with the date. You can pull the data
by using a different textbox, say called txtDate, bound to the tblDate.Field

Dim dtLast as Date

dtLast = Me.txtDate

Me.YourTextBox = dtLast
 
That text box should, indeed be unbound.
You can use the Default Value property of the text box to retrieve that date.

"SELECT [last_update_date] FROM tblDATE;"

The above assumes this is a one record table.
 
Susan,
See my earlier response. It is much simpler. Also, you cant bind a control
to a a field that is not in the form's recordsource.
 
Klatuu,

Yes I did see your response - much slicker! As to the not bound part, I was
going on where he said he had bound the textbox...

Your method is much simpler - I'll keep that in mind for sure! Every day I
learn new stuff here - the problem is remembering it all

=)
 
Klatuu said:
That text box should, indeed be unbound.
You can use the Default Value property of the text box to retrieve that date.

"SELECT [last_update_date] FROM tblDATE;"

The above assumes this is a one record table.


Not sure what you're saying here. I tried setting a text
box's DafaultValue property to a select statement, and get
some funky message about an illegal subquery - Huh? Adding
the suggested ( ) around it got rid of the error, but the
default that shows up in the text box is the Select
statement (without the parens and semicolon so some kind of
processing is going on). Adding qoutes around the whole
thing makes no difference in that the quotes, parens and
semicolon are still removed - double Huh?

I've always use a DLookup for this kind of thing, but I'm
certainly open to other approaches.
 
Sorry, it was untested air code. I have used select statements like this
before without problem but it has been a while and I can't remember exactly
how I did it. I think the DLookup would be just as good and less hassle.

Marshall Barton said:
Klatuu said:
That text box should, indeed be unbound.
You can use the Default Value property of the text box to retrieve that date.

"SELECT [last_update_date] FROM tblDATE;"

The above assumes this is a one record table.


Not sure what you're saying here. I tried setting a text
box's DafaultValue property to a select statement, and get
some funky message about an illegal subquery - Huh? Adding
the suggested ( ) around it got rid of the error, but the
default that shows up in the text box is the Select
statement (without the parens and semicolon so some kind of
processing is going on). Adding qoutes around the whole
thing makes no difference in that the quotes, parens and
semicolon are still removed - double Huh?

I've always use a DLookup for this kind of thing, but I'm
certainly open to other approaches.
 
Back
Top