I am trying to retrive one field from the "company info" table that
contains several fields but I want the "company name" field. There is
only one record in this table. When I entered the code below (which I
copied out of a book). I get the following error. The hickup comes in
the "dim db as database" line. However if I comment this out. It
doesn't like the next line either.
I appreciate any help you can give me. Also is this a problem between
ADO and DAO?
Error I receive is:
Microsoft Visual Basic
! Compile Error:
User-defined type not defined
Private Sub Form_Load()
Dim db as database
Dim rst as recordset
Dim strsql as string
Dim coname as string
Set db = currentdb
strsql = "select [company name] from [company info]"
set rst=db.openrecordset(strsql)
rst.movelast
rst.movefirst
coname=rst!("company name")
me.txtcompanyname = coname
rst.close
Set rst = nothing
Set db = nothing
End Sub
Thanks for all your help in advance!
Chuck