peebman2000
Programmer
Hello I’m new to the forum and I’m a beginner programmer working as an intern programmer with the government. I’m researching to find code to create an edit button for a vb form that’s been created in ms access. I need the edit button to unlock the controls or fields in the form and allow the user to edit the field. Currently the fields are locked when the user saves the data in the form, they can’t go back an edit certain fields because they are locked. This may be confusing but below is the code I inherited from someone else, (who no longer works here). I think if you look at the code, someone will understand what i'm talking about. I need an edit button to unlock those fields and allow the user to update them. Does anyone have any suggestions or code that may allow the user to do this with an edit button? I would appreciate the help, thanks.
Private sub form_current()
blnOlChangedOnly = True
Me!cboStatus.SetFocus
If Me!cboStatus <30 then ‘ less than the status code of 30, there are 5 status codes 0,1,2,9,11, and 30 in the table
Unlock_Controls
Else
Lock_Controls
End If
End Sub
Private Sub Lock_Controls()
Me!cboFy.Locked = True
Me!cboFy.TabStop = False
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect = 0
Me!DateReceived.Locked = True
Me!DateReceived.TabStop = False
Me!DateReceived.BackColor = clrWhite
Me!DateReceived.SpecialEffect = 0
Me!cboFy.Locked = True
Me!cboFy.TabStop = False
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect = 0
‘There are more fields, but this is just to give you and idea
End Sub
Private Sub Unlock_Controls()
Me!cboFy.Locked = False
Me!cboFy.TabStop =True
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect = 2
Me!DateReceived.Locked = False
Me!DateReceived.TabStop = True
Me!DateReceived.BackColor = clrWhite
Me!DateReceived.SpecialEffect =2
Me!cboFy.Locked = False
Me!cboFy.TabStop =True
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect =2
‘there are more fields, but this is just to give you and idea
End Sub
Private sub form_current()
blnOlChangedOnly = True
Me!cboStatus.SetFocus
If Me!cboStatus <30 then ‘ less than the status code of 30, there are 5 status codes 0,1,2,9,11, and 30 in the table
Unlock_Controls
Else
Lock_Controls
End If
End Sub
Private Sub Lock_Controls()
Me!cboFy.Locked = True
Me!cboFy.TabStop = False
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect = 0
Me!DateReceived.Locked = True
Me!DateReceived.TabStop = False
Me!DateReceived.BackColor = clrWhite
Me!DateReceived.SpecialEffect = 0
Me!cboFy.Locked = True
Me!cboFy.TabStop = False
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect = 0
‘There are more fields, but this is just to give you and idea
End Sub
Private Sub Unlock_Controls()
Me!cboFy.Locked = False
Me!cboFy.TabStop =True
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect = 2
Me!DateReceived.Locked = False
Me!DateReceived.TabStop = True
Me!DateReceived.BackColor = clrWhite
Me!DateReceived.SpecialEffect =2
Me!cboFy.Locked = False
Me!cboFy.TabStop =True
Me!cboFy.BackColor = clrWhite
Me!cbofy.SpecialEffect =2
‘there are more fields, but this is just to give you and idea
End Sub