vba - Inserting values into previously null fields, locking them -
i'm working in ms access 2013 , want write vba code button made on form. want code 2 things: insert values designate null fields , lock fields in form.
accmdfreezecolumn doesn't seem appropriate since doesn't refer form. current thought use framework:
sub buttonlockform1_click() dim intresponse integer intresponse = msgbox( _ prompt:="are sure want lock form?", _ buttons:=vbyesno + vbquestion + vbdefaultbutton2, _ title:="lock form?") if intresponse = vbyes ... ... else: if intresponse = vbno exit sub end if end sub
any can provide appreciated!
i'm guessing mean controls on form (like textboxes). null , empty strings different in vba btw. put inside if (and dim @ top obviously)
dim ctl control each ctl in me.controls if isnull(ctl.value) or ctl.value = "" _ ctl.value = "value want save" if ctl.name <> "name of control don't want lock, buttons" _ ctl.enabled = false next ctl
controlname.enabled = false makes control greyed out , locks it. can use controlname.visible = false make invisible, , controlname.locked = false make still white bg, lock disabling editing.
Comments
Post a Comment