error with my ADO code!

G

Guest

hi everyone, i have the following ADO code in an access2003 database, which
isnt working. its supposed to bring up the city that a building belongs to
and put it into the city field, it looks right but when it gets to the
rstCity.Open line it throws up the following runtime error:

Run time error '-214721.....(80040e10)'
No value given for one of more required paramters.
<!----------
Dim ConDatabase As ADODB.Connection
Dim rstCity As ADODB.Recordset
Dim strSql As String

' Initialize Connection object
' Specify current database as the Provider and then open the database
Set ConDatabase = CurrentProject.Connection
Set rstCity = New ADODB.Recordset

strSql = "SELECT CITY" & " FROM STUDENTROOMS where (BUILDING = '" &
Forms!studentsnew!Building & "');"
rstCity.Open strSql, ConDatabase, adOpenForwardOnly, adLockReadOnly, adCmdText

'Me![City] = rstFlat.Fields(0).Value

' Close Connection object and destroy object variable.
rstCity.Close
ConDatabase.Close

Set rstCity = Nothing
Set ConDatabase = Nothing
------------------->

whats going on
 
D

Douglas J Steele

What's actually in strSQL when your query runs? What happens if you paste
that into the SQL View window and run it?

Odds are one of CITY, STUDENTROOMS or BUILDING isn't correct for the table
you're querying.
 
G

Guest

Clever man, it was supposed to be BuildingRef!!!thank you ever so much for
this, its been teasing me for few days now!
Where can i see what the specific error messages mean, when i typed it into
help then i got lots of information about labels on a form and how to make
them do amazing things instead!

with much thanks,

Amit
 

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