putting value from SQL Server view into form control

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

Guest

Hi,
I have an access project linked to an SQL Server database. I want to put a
value which is the result of an SQL View into a text bos on a form. How do I
do this?

Many thanks,
Pete
 
I have an access project linked to an SQL Server database. I want to
put a
value which is the result of an SQL View into a text bos on a form.
How do I do this?

' this is air code; i'm not very good at ado...

dim rst as recordset

set rst = new recordset
with rst
' set up the recordset. I think the cursor
' defaults to a read only forwardonly, so that is fine
' but you need to check
.activeconnection = currentproject().Connection

' define the query
.sql = "select max(height) as Tallest from schoolchildren"

' get the data
.open

' and send it where you want it
me!txtTextBox.Value = .Fields("Tallest")

.close
end with


This does the same thing, only with less work on your behalf:

me!txtTextBox.Value = DMax("Height", "SchoolChildren")

Best wishes


Tim F
 
Back
Top