Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create a edit button in a vb form in ms access 2

Status
Not open for further replies.

peebman2000

Programmer
Nov 28, 2006
30
US
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
 
Why not just use the Allow Edits property of the form?
 
Simply call the Unlock_Controls procedure in the Click event procedure of your button.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top