Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2007

Tip: Looking for answers? Try searching our database.

Using CASE statement in a Report to auto-generate the Subnet & Gateway

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cw - 21 May 2007 14:50 GMT
I have the following code to calculate the correct SUBNET mask & GATEWAY
(depending on the third part of the IP Address txtPartIII):
----------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Select Case Me.txtPartIII
  Case Is = "248"
      Me.txtSubNetMask = "255.255.255.0"
      Me.txtGateway = "64.83.248.1"
  Case Is = "252"
      Me.txtSubNetMask = "255.255.255.248"
      Me.txtGateway = "10.0.0.1"
  Case Is = "253"
      Me.txtSubNetMask = "255.255.255.252"
      Me.txtGateway = "10.0.0.1"
     End Select
End Sub
--------------------------------

My problem is with the Gateway on the Second IP address (see sample below):
- The IP addresses are a "stored" value in the database. Subnet & Gateway are
not.
- When the Report is generated, all of the Subnets & Gateways calculate fine
except the Gateway for the second IP address. Here is an example of what the
first two should be when printed:

Static IP: 64.83.253.105
Subnet: 255.255.255.252
Gateway: 10.0.0.1   <---------------

Static IP: 64.83.253.106
Subnet: 255.255.255.252
Gateway: 64.83.253.105   <------------

The first Gateway is always 10.0.0.1
The second Gateway is always the same as the first IP address.
How would I alter my code above to correctly generate that second Gateway so
that it is the same as of the first IP address?

Thanks for any tips,
cw
Perry - 21 May 2007 22:48 GMT
check VBA help on Split() function

If your Access form is designed ok, you textbox (IP input control) is set
correctly, you're expecting
a valid IP address. Ok? (I take this one for granted...)

Following sequence let's you determine wheter the third part of your IP
address matches
a criterion (in this case 255):

Dim sIP as string
sIP = Split("192.148.255.0")(2)
If sIP = "255" Then
   MsgBox "Eureka 255"
End if

Also check out VBA help on Split() function
Good luck

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

>I have the following code to calculate the correct SUBNET mask & GATEWAY
> (depending on the third part of the IP Address txtPartIII):
[quoted text clipped - 41 lines]
> Thanks for any tips,
> cw
Perry - 22 May 2007 00:18 GMT
Replace
> sIP = Split("192.148.255.0")(2)

by
sIP = Split("192.148.255.0", ".")(2)

Notice: I forgot the dot delimiter to the Split() function
-
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE

> check VBA help on Split() function
>
[quoted text clipped - 68 lines]
>> Thanks for any tips,
>> cw
jalexander - 22 May 2007 04:21 GMT
Perry, Thanks so much for your help.

I need to apologize in that I posted this question in Forms and not Reports.
Anyway, I looked up the Split function & look forward to trying it out.

What I have is an IP Database with customers already assigned. Some customers
have 1 IP, some 2 and others have 5 or more. I have a button on my form
called "Email IP info" which runs a query, generates my IP Report to PDF and
attaches it to an email. Everything works perfectly except that my code to
auto-generate the Gateway needs refinement.

Here is the text of what my report outputs:
--------------------------------------------------
Total Customer IP Address(s) 2

Customer IP Address #1 64.83.292.17
Subnet Mask 255.255.255.248
Gateway 10.0.0.1

Customer IP Address #2 64.83.292.18
Subnet Mask 255.255.255.248
Gateway 10.0.0.1
---------------------------------------------------
For this report, the second Gateway should have been 64.83.292.17
How do I alter my code in the report to make the second Gateway the first IP
minus 1. ?

I will experiment with the Split function in the meantime.
Thanks again,
cw

>Replace
>> sIP = Split("192.148.255.0")(2)
[quoted text clipped - 16 lines]
>>> Thanks for any tips,
>>> cw
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.