Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,648
- Office Version
- 365
- 2016
- Platform
- Windows
This is likely a pretty basic concept, but I'm struggling.
How does one manipulate userform controls from a procedure in a module? For example, I have this procedure (frm_reset) in a module. It essentially is designed to reset the user controls in (on?) my userform "IFM_Title" to their defaults.
The line in red leaves me with a "Type mismatch error". I tried "With Me" and goit an "Invalid use of Me keyword (clearly I have no concept of when to use Me). If I exclude the "With ... End With", the controls give me "Object required" errors. If I preceed the control with "Userforms ("IFM_Title") I get the "Type mismatch" error.
What is the proper way of doing what I wish to do.
How does one manipulate userform controls from a procedure in a module? For example, I have this procedure (frm_reset) in a module. It essentially is designed to reset the user controls in (on?) my userform "IFM_Title" to their defaults.
Rich (BB code):
Sub frm_reset()
mbevents = False
Dim mcnt As Long
With UserForms("IFM_Title")
cbx_pmodel.Value = ""
cbx_res = ""
cbx_res.Locked = True
tbx_title.Value = ""
chkbx_collected.Value = False
chkbx_collected.Locked = True
chkbx_np.Value = False
chkbx_np.Locked = True
tbx_titlecnt.Value = ""
tbx_titlecnt.Locked = True
tbx_checkedcnt.Value = ""
tbx_checkedcnt.Locked = True
tbx_collectedcnt.Value = ""
bx_collectedcnt.Locked = True
tbx_date.Value = ""
tbx_date.Locked = True
tbx_dur.Value = ""
tbx_dur.Locked = True
chkbx_group.Value = False
chkbx_group.Locked = True
With lbx_smodel
.Height = 76
.Value = ""
.Visible = False
.Locked = True
End With
lbl_smodel.Visible = False
tbx_collections.Clear
cbtn_submit.Enabled = False
cbtn_delete.Enabled = False
cbtn_edit.Enabled = False
uniquelist2 'creates model list in dump
mcnt = ws_modlist.Columns(12).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row - 1
lbl_pmodel.Caption = "Primary Model (" & mcnt & " models)"
lbl_smodel.Caption = "Secondary Model(s) (" & mcnt & " models)"
cbx_pmodel.List = Application.WorksheetFunction.Transpose(ThisWorkbook.names("modlist").RefersToRange)
lbx_smodel.List = Application.WorksheetFunction.Transpose(ThisWorkbook.names("modlist").RefersToRange)
With cbx_res
.AddItem = "8k (7680x4320)"
.AddItem = "4k (3840x2160)"
.AddItem = "2k (2560x1440)"
.AddItem = "HD2 (1920x1080)"
.AddItem = "HD1 (1280x720)"
.AddItem = "SD3 (854x480)"
.AddItem = "SD2 (640x360)"
.AddItem = "SD1 (426x240)"
End With
End With
mbevents = True
End Sub
The line in red leaves me with a "Type mismatch error". I tried "With Me" and goit an "Invalid use of Me keyword (clearly I have no concept of when to use Me). If I exclude the "With ... End With", the controls give me "Object required" errors. If I preceed the control with "Userforms ("IFM_Title") I get the "Type mismatch" error.
What is the proper way of doing what I wish to do.