Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
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 24th, 2004, 01:55 PM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default Problem putting code on the right event - SubForm


   I have a form (frmComputer) that I want to use as a subform.
   An IP Address is shown in a text box on the form (frmComputer) called "DHCP".
   I have another Text Box on frmComputer called "TextBox" where I want to show the location of an IP Address.
   As a Form (frmComputer), this code works...
   I have this code in the On Current event of the form:

Private Sub Form_Current()

    Dim strIP As String
    Dim strIPLoc As String

    strIP = Me.DHCP

If Left(strIP, 9) = "172.17.14" Then
    strIPLoc = "ACF"
ElseIf Left(strIP, 9) = "172.17.27" Then
    strIPLoc = "Campus"
ElseIf strIP = "" Or strIP = "Null" Then
    strIPLoc = "No IP Address"
Else: strIPLoc = "Unknown"
End If

Me.TextBox = strIPLoc

End Sub

However, when I make this form (frmComputer) into a subform by dropping it onto another form (frmEmployee) and linking them, when I try to open the new form (frmEmployee with frmComputer) I get an error message that says Access cannot find frmComputer.

I have moved the text box to frmEmployee and referred to DHCP as Forms!frmComputer.DHCP, and moved the code to the form frmEmployee's On Click event, and I get a similar error.

As I said, I know the code works when the sub form is a stand alone form, but when I make it a sub form (properly linked) it doesn't work.

I need to put this code on the right event. I am not sure if I need to use a module, but if I did, this code would need to change, and I am not sure how.



Look it up at: http://wrox.books24x7.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
Subform problem fatrich Access VBA 6 October 4th, 2007 08:02 PM
Click event on a subform cesather Access 3 December 14th, 2005 05:41 PM
Reaching a subform through code ! penta Access 23 April 5th, 2005 05:50 AM
putting piece of code into a string .... elladi Classic ASP Basics 0 December 23rd, 2004 12:27 AM
Urgent!! code for no match in Subform based query smercer Access 3 September 10th, 2004 11:15 PM

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