Results 1 to 7 of 7
  1. #1
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206

    Post How to dereference a variable.


    Hi guys!

    I want to know what's the proper way of dereferencing variables, as I'm a programming novice.

    I have...

    Code:
    Private Function Something(ByVal SomethingElse AS String) AS Integer
       Dim db AS DAO.Database
       Dim rs AS DAO.Recordset
    
       Set db = CurrentDB
       Set rs = db.OpenRecordset("SELECT TOP 1...")
    
       Something = rs.Fields("...").Value
    
       ???I dont know what to do next... 
    End Function
    Please help. Thanks a lot.

    Joe

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Set db = Nothing
    Set rs = Nothing

  3. #3
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    Thanks! I'll mark this solved.

  4. #4
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    All the custom functions in my db are not de-referenced. Will they cause any serious problems? I'm doing my homework... But it's painful to learn by experience.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Technically, Access should DeReference the variables when the function goes out of scope but most developers do not leave it up to Access. It has not always worked in the past.

  6. #6
    evander is offline Competent Performer
    Windows 7 Access 2003
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    206
    Okay, I will insert the set nothing codes tonight. Thanks mod.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad we could help here.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  2. Using a string variable to specify a control
    By Gerry in forum Programming
    Replies: 3
    Last Post: 04-14-2010, 02:28 PM
  3. Replies: 5
    Last Post: 04-05-2010, 11:43 AM
  4. Variable Criteria
    By JamesLens in forum Queries
    Replies: 0
    Last Post: 01-02-2009, 04:55 PM
  5. Variable question
    By synapse5150 in forum Programming
    Replies: 1
    Last Post: 07-09-2008, 08:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums