Ahh yes, I forgot about that...
This is the code, it's all for the user form code module.
The control names in the example probably need to change for your form - this example uses a form with:
A TextBox named txtPost
A commandBottun named cmdSavePost[VBA]'declaring the variable at the head of the form code means:
'it's "scope" is limited to the routines and functions in the form code
'it's "lifetime" is the same as the form (all the time it's loaded)
Dim strUserRole As String
Private Sub UserForm_Initialize()
'disable the save button
cmdSavePost.Enabled = False
'init the variable from the registry
'if not set, will return "None saved"
strUserRole = GetSetting( _
"FOI", "UserProfile", "Role", "None saved")
'populate the textbox from the variable
txtPost.Text = strUserRole
End Sub
Private Sub txtPost_Change()
'whenever the text is changed, if it doesn't
'match the variable, enable the save button
If Trim(txtPost.Text) <> strUserRole Then
cmdSavePost.Enabled = True
Else
cmdSavePost.Enabled = False
End If
End Sub
Private Sub cmdSavePost_Click()
strUserRole = Trim(txtPost.Text)
SaveSetting "FOI", "UserProfile", "Role", strUserRole
End Sub
'when building the file name, you can use txtPost.Text -
'it may be different from the variable and saved setting
'but that gives the user the facility to use the form
'as a different user
'if you want to avoid this, you can force the UserRole
'save by running the cmdSavePost_Click routine at the
'start of the "Save with Filename" button's click event[/VBA]