assign value to text box based on what form is open

D

Donna

I need to assign a value to a text box depending on what form is open. I
have the following code in the "OnOpen" event of "frmCompSW".

Dim strForm1 As String, strForm2 As String
strForm1 = "frmSWInvAll"
strForm2 = "frmSWInv"
If CurrentProject.AllForms(strForm1).IsLoaded Then
Me.SWPID = Form_frmSWInvAll.SWPID
Else
If CurrentProject.AllForms(strForm2).IsLoaded Then
Me.SWPID = Form_frmSWInv.SWPID
End If
End If

When strForm1 is loaded I get an error message that I can't assign a value
to Me.SWPID. It shows me that the Form_frmSWInv.SWPID value is 13 so it's
finding that. It just won't assign that value to SWPID on the frmCompSW.

The same error occurs when strForm2 is open.

Any idea why or what I need to do? I was using a default value, but then I
deleted that because I needed the value to come from one of these 2 forms.
 
Top