Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 9th, 2004, 04:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default Table Look Up and Comparison

Hi,

   Here's an interesting question:

   I have a table that looks like this:

tblSubNet
   PK IPID
   IPAddress
   Location
   Status

   I have another table that has among other things, the following:

tblComputer
   PK PCID
   ComputerName
   UserName
   IPAddress

   On a case by case basis, I want to look up the IPAddress of a computer from the tblComputer table (XXX.XXX.XXX.XXX), look for the first three octets in the tblSubNet.IPAddress (XXX.XXX.XXX), and based on a comparison, find the Location of the ComputerName.

   Example data:

tblSubNet
   PKID: 1
   IPAddress: 192.168.0
   Location: Home
   Status: Home User

tblComputer
   PCID: 1
   ComputerName: MyComputer
   UserName: mmcdonal
   IPAddress: 192.168.0.100

   Based on the location of the subnet in the first table, I want to determine (in a report) the location of the computer called MyComputer.

   I am thinking I will need a Module that looks through tblComputer where the PCID on the report line matches the PCID in the table, then reads the IPAddress, uses an array to break it into its constituent parts, then looks up the first octet in tblSubNet, then based on that filter, looks up the second octet, then based on that filter, looks up the third octet, and returns the Location based on the final match. The Subnets are unique (so an autonumber PK isn't really needed.)

   Here's another kicker: This is an Access .mdb file, and the tables are all linked to a SQL server.

   Yee-Ha!

mmcdonal
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old November 17th, 2004, 05:28 PM
Registered User
 
Join Date: Nov 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is what I'm doing
SELECT Location
FROM dbo_tblSubNet where IPAddress in
(SELECT left(IPAddress,9) from dbo_tblComputer where IPAddress Like '192.168.0*' and ComputerName = 'MyComputer')







Similar Threads
Thread Thread Starter Forum Replies Last Post
Array or Table Performance comparison bananas SQL Language 4 June 5th, 2007 05:29 AM
datetime comparison MunishBhatia ASP.NET 2.0 Professional 2 May 24th, 2007 07:42 AM
Date comparison rajuru Beginning PHP 2 February 19th, 2005 10:33 AM
Table comparison damnnono_86 Access 7 October 29th, 2003 10:36 AM
Comparison in Access mega Access ASP 1 June 23rd, 2003 12:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.