Connecting Tech Pros Worldwide Forums | Help | Site Map

Run-Time Error 91

Newbie
 
Join Date: Nov 2007
Posts: 15
#1: Nov 8 '07
Thank you in advance for your help.

When I run the following I get a "Run-Time Error 91: Object variable or With block variable not set"



Expand|Select|Wrap|Line Numbers
  1.  Function GetAddress() As Hyperlink 
  2.  
  3. Dim dbLogBook As DAO.Database
  4. Dim tblStation As DAO.Recordset
  5. Dim strSQL As String
  6. Dim hypAddress As Hyperlink
  7.  
  8. Set dbLogBook = CurrentDb
  9.  
  10. strSQL = "SELECT A1 FROM tblStation"
  11.  
  12. Set tblStation = dbLogBook.OpenRecordset(strSQL)
  13.  
  14. hypAddress = tblStation("A1")
  15.  
  16. tblStation.Close
  17.  
  18. GetAddress = hypAddress
  19.  
  20. End Function
  21.  


It is having a hang up on this line "hypAddress = tblStation("A1")"

If I set "hypAddress" of course I get a "Type Mismatch"

What am I doing wrong?

Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#2: Nov 8 '07

re: Run-Time Error 91


The Hyperlink object represents a hyperlink associated with a control on a form, report, or data access page. What is it you're trying to do?
Newbie
 
Join Date: Nov 2007
Posts: 15
#3: Nov 8 '07

re: Run-Time Error 91


I was able to fix it I wasn't using a variant

Thanks for your help
Rabbit's Avatar
Expert
 
Join Date: Jan 2007
Location: California
Posts: 3,835
#4: Nov 8 '07

re: Run-Time Error 91


Good luck.
Reply