ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Edit Forms (https://www.excelbanter.com/excel-programming/362021-edit-forms.html)

Steve

Edit Forms
 
I know how to create a form to add records in Excel. My need is to create a
form that allows a user to edit an existing record, without allowing the
user to delete a record. Can someone point me in a helpful direction?

--
Steve



Tom Ogilvy

Edit Forms
 
in you code to load the record, you would just use code like

Textbox1.Text = Cells(i,1)
TextBox2.Text = Cells(i,2)

then to write it back, you similar code to that which you say you know.

Cells(i,1) = Textbox1.Text
Cells(i,2) = Textbox2.Text

--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
I know how to create a form to add records in Excel. My need is to create

a
form that allows a user to edit an existing record, without allowing the
user to delete a record. Can someone point me in a helpful direction?

--
Steve





Steve

Edit Forms
 
Tom
I get the general idea but, there may be a thousand or so records. Would
there be a way to load the data and filter it down (example by date or user
loginID)?

--
Steve

"Tom Ogilvy" wrote in message
...
in you code to load the record, you would just use code like

Textbox1.Text = Cells(i,1)
TextBox2.Text = Cells(i,2)

then to write it back, you similar code to that which you say you know.

Cells(i,1) = Textbox1.Text
Cells(i,2) = Textbox2.Text

--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
I know how to create a form to add records in Excel. My need is to create

a
form that allows a user to edit an existing record, without allowing the
user to delete a record. Can someone point me in a helpful direction?

--
Steve







Steve

Edit Forms
 
Tom

I think I have it.
If userID = "whatever" Then
TextboxLinenumber = i
...
end if

Correct?

Steve

"Steve" <No Spam wrote in message ...
Tom
I get the general idea but, there may be a thousand or so records. Would
there be a way to load the data and filter it down (example by date or
user loginID)?

--
Steve

"Tom Ogilvy" wrote in message
...
in you code to load the record, you would just use code like

Textbox1.Text = Cells(i,1)
TextBox2.Text = Cells(i,2)

then to write it back, you similar code to that which you say you know.

Cells(i,1) = Textbox1.Text
Cells(i,2) = Textbox2.Text

--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
I know how to create a form to add records in Excel. My need is to
create

a
form that allows a user to edit an existing record, without allowing the
user to delete a record. Can someone point me in a helpful direction?

--
Steve









Tom Ogilvy

Edit Forms
 
turn on the macro recorder, then do
Edit=Find
and use Whatever as the search term

then change the recorded code from

Selection.Find(what:="Whatever", . . .).Activate

to
set rng = Columns(1).find(What:="Whatever", . . .)
if not rng is nothing then
' cell was found
with userform1
.textbox1.Text = rng
.textbox2.Text = rng.offset(0,1)
End With
else
' not found
End if


or if you want to loop through your data, you can use your approach.
--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
Tom

I think I have it.
If userID = "whatever" Then
TextboxLinenumber = i
...
end if

Correct?

Steve

"Steve" <No Spam wrote in message ...
Tom
I get the general idea but, there may be a thousand or so records. Would
there be a way to load the data and filter it down (example by date or
user loginID)?

--
Steve

"Tom Ogilvy" wrote in message
...
in you code to load the record, you would just use code like

Textbox1.Text = Cells(i,1)
TextBox2.Text = Cells(i,2)

then to write it back, you similar code to that which you say you know.

Cells(i,1) = Textbox1.Text
Cells(i,2) = Textbox2.Text

--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
I know how to create a form to add records in Excel. My need is to
create
a
form that allows a user to edit an existing record, without allowing

the
user to delete a record. Can someone point me in a helpful direction?

--
Steve











Steve

Edit Forms
 
Tom

Looping is slow. That's enough to work with. Thank you.

--
Steve


"Tom Ogilvy" wrote in message
...
turn on the macro recorder, then do
Edit=Find
and use Whatever as the search term

then change the recorded code from

Selection.Find(what:="Whatever", . . .).Activate

to
set rng = Columns(1).find(What:="Whatever", . . .)
if not rng is nothing then
' cell was found
with userform1
.textbox1.Text = rng
.textbox2.Text = rng.offset(0,1)
End With
else
' not found
End if


or if you want to loop through your data, you can use your approach.
--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
Tom

I think I have it.
If userID = "whatever" Then
TextboxLinenumber = i
...
end if

Correct?

Steve

"Steve" <No Spam wrote in message ...
Tom
I get the general idea but, there may be a thousand or so records.
Would
there be a way to load the data and filter it down (example by date or
user loginID)?

--
Steve

"Tom Ogilvy" wrote in message
...
in you code to load the record, you would just use code like

Textbox1.Text = Cells(i,1)
TextBox2.Text = Cells(i,2)

then to write it back, you similar code to that which you say you
know.

Cells(i,1) = Textbox1.Text
Cells(i,2) = Textbox2.Text

--
Regards,
Tom Ogilvy


"Steve" <No Spam wrote in message ...
I know how to create a form to add records in Excel. My need is to
create
a
form that allows a user to edit an existing record, without allowing

the
user to delete a record. Can someone point me in a helpful direction?

--
Steve














All times are GMT +1. The time now is 02:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com