Instead of creating your own form, you may find it easier to use John
Walkenbach's Enhanced Data Form. It's a free add-in, allows combo boxes,
and has unlimited fields.
http://j-walk.com/ss/dataform/index.htm
You could use it to find and edit records in the database.
gregork wrote:
I have created a userform for enter data on to a sheet. I now want to have
an edit function on the user form so I can correct any errors via the same
form. I'm not sure of the right way to go about this so I would really
appreciate any advice or sample codes. Here's the code for the data entry
( I am planning to run the edit on command button4) :
Private Sub UserForm_Initialize()
Dim i As Integer
For i = 3 To 500
Me.ComboBox1.AddItem Worksheets("Raw Material").Cells(i, 1)
ComboBox1.Value = ""
TextBox1.Value = ""
Next
End Sub
Private Sub CommandButton1_Click()
Dim LastRow As Object
Set LastRow = Worksheets("Blend Sheet").Range("B22").End(xlUp)
LastRow.Offset(2, 0).Value = ComboBox1.Text
LastRow.Offset(2, 3).Value = TextBox1.Text
MsgBox "Record Written to Blend Sheet"
response = MsgBox("Do you want to enter another record?", vbYesNo)
If response = vbYes Then
ComboBox1.Text = ""
TextBox1.Text = ""
ComboBox1.SetFocus
Else
Unload Me
End If
End Sub
-------------------------------
Regards
gregork
--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html