Solved

when DLookup function returns a NULL

Posted on 1998-07-29
3
225 Views
Last Modified: 2008-03-03
I am trying to write a sub that will loop through my tables to check if there is an entry in each table for a given subject number.  The DLookup function is the only way I know  to read data from other tables (besides the one the form is based on) but the sub stops running every time DLookup returns a null.  Should I be using a different function or is there a way to disable the error message that appears every time DLookup returns a null?
0
Comment
Question by:alina072998
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
devtha earned 100 total points
Comment Utility
This example opens a Recordset and locates each record whose Title field satisfies the search criteria and copies it to the copy buffer.  The example prepares the record for subsequent editing, changes the job title, and saves the change using the Update method.

Dim Criteria As String, MyDB As Database, MySet As Recordset
Dim NewTitle As String
Criteria = "Title = 'Sales Representative'"      
' Set search criteria.
NewTitle = "Account Executive"      ' Set new job title.
Set MyDB = DBEngine.Workspaces(0).Databases(0)
Set MySet = MyDB.OpenRecordset("Employees", DB_OPEN_DYNASET)  
' Create dynaset.
MySet.FindFirst Criteria      ' Find first occurrence.
Do Until MySet.NoMatch      ' Loop until no matching records.
      MySet.Edit                  ' Enable editing.
      MySet!Title = NewTitle      ' Change title.
      MySet.Update            ' Save changes.
      MySet.FindNext Criteria      ' Find next occurrence.
Loop                         ' End of loop.


0
 

Author Comment

by:alina072998
Comment Utility
Thanks.  I think I get it.  To look through all of my tables for the same variable,
I would need to repeat the routine but change this:

Set MySet = MyDB.OpenRecordset("Employees", DB_OPEN_DYNASET)

statement, replacing the table name each time?
  
0
 
LVL 6

Expert Comment

by:devtha
Comment Utility
YOU GOT IT EXACTLY. BULL's EYE
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now