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

  • Thread starter Thread starter cw via AccessMonster.com
  • Start date Start date
C

cw via AccessMonster.com

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
 
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
 
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



Perry said:
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
 
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)

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]
 
Back
Top