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"
Me.TextBox = strIPLoc
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