By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,775 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,775 IT Pros & Developers. It's quick & easy.

Forms and SQL

P: n/a
I am trying to write the value of an sql statement into a text box.

When the code below runs the statement itself is put into the textbox,
i guess this is because of the quotes, but if i remove them i get an
error message.

CODE
--------------------
strWhere = "SELECT COUNT(*) FROM [Waiting List]"
Me.TextField = strWhere
--------------------

How can i store the value of my select statement into a variable then
put that value into a form textbox?

Thanks

Mar 4 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
sc************@yahoo.co.uk wrote:
I am trying to write the value of an sql statement into a text box.

When the code below runs the statement itself is put into the textbox,
i guess this is because of the quotes, but if i remove them i get an
error message.

CODE
--------------------
strWhere = "SELECT COUNT(*) FROM [Waiting List]"
Me.TextField = strWhere
--------------------

How can i store the value of my select statement into a variable then
put that value into a form textbox?

Thanks
Me.TextField = DCount("*", "Waiting List")
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Mar 4 '07 #2

P: n/a
Thank you Rick, it worked great
Mar 5 '07 #3

P: n/a
A more complicated way of doing it may also be more useful, if what you're
trying to get isn't available via a built-in function. For example, here I
want to pull a value from a particular record in my dataset:

Dim rs As Recordset
Set rs = db.OpenRecordset("Select left(Dept,4) From [" & TblNam & "]" &
_
"Where Left(RecTyp, 7) = 'Grants-'", dbOpenSnapshot)
MaxPg = rs.Fields(0).Value 'The department prefix
Set rs = Nothing

This assumes that there is only one record that fits my WHERE criterion, of
course.

<sc************@yahoo.co.ukwrote in message
news:11**********************@64g2000cwx.googlegro ups.com...
>I am trying to write the value of an sql statement into a text box.

When the code below runs the statement itself is put into the textbox,
i guess this is because of the quotes, but if i remove them i get an
error message.

strWhere = "SELECT COUNT(*) FROM [Waiting List]"
Me.TextField = strWhere

How can i store the value of my select statement into a variable then
put that value into a form textbox?

Mar 6 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.