Hi,

I've drawn a bit of a blank with this one.

I would like to assign a form username to a variable that I can then reference from another module. The reason for this is that I have a few userforms that are slightly different in terms of content and layout but share many similarities in function. To keep everythign a bit neater i'd like to hold most of the 'doing' code within a module and then call it as required from the userform code.

I understand that I can .show a userform via this method, but not sure if it's possible to reference it for other purposes - e.g. populating a combobox list.

The code setup I have at present:

Userform (TransForm1):
Private Sub ComboBox2_Change()

    FormName = "TransForm1"
    Set CurrForm = UserForms.Add(FormName)
    CurrCB = 2
    
    Call POSType
End Sub
Module1:
Public FormName As String
Public CurrCB As Integer
Public CurrForm As Object

Sub POSType()
    
    Select Case CurrForm.Controls("ComboBox" & CurrCB)
    
        Case "POS CNP"
            
            With CurrForm.Controls("ComboBox" & CurrCB + 1)
                .Clear
                .List = Application.Transpose(Range("POSCNP"))
            End With
            
        Case "POS CP"
        
            With CurrForm.Controls("ComboBox" & CurrCB + 1)
                .Clear
                .List = Application.Transpose(Range("POSCP"))
            End With
                
        Case "ATM (CP)"
        
            With CurrForm.Controls("ComboBox" & CurrCB + 1)
                .Clear
                .List = Application.Transpose(Range("ATMCP"))
            End With
            
    End Select

End Sub
This in itself doesn't trigger any runtime errors (though it does trigger the userform initialise event again when it reaches 'Set CurrForm', I have a bit of code to work around that) but when it comes to the Case Select statement it doesn't register any of the cases as true - leading me to suspect that it isn't carrying over the Userform name properly. This code ran fine when the POSType sub was within the userform module.

So any ideas? Can it be done? Or do I need to just copy and paste the code and live with it being messy?