Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Writing data back via a userform

Hi everyone. I created a pretty large userform. I then created 2 buttons
on the Excel worksheet that calls the Userform- one for a New entry, andone
for an edit to an existing entry. The form has an "Enter" button that
initates the writing to the database.

The way I have it set up now, both buttons (edit and new) call the same
userform. Ideally, I would like the following pseudo-code:

If the New button is pushed, call Userform1, and when "Enter" is pushed
write data entered to the bottom of the database,

Else if Edit button is pushed, call Userform1, and when "Enter" is pushed
write data back to the row that was edited.

I don't know if this can be done without creating an entirely new userform,
or at least another "Enter" button. But I'd like to simply use the 1 form
and 1 enter botton. Can you help?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 227
Default Writing data back via a userform

As you have two buttons on the worksheet to call the UserForm, use something
like the following to open the UserForm

For the button that creates a new entry:-
Sub test1()
UserForm1.Caption = "New Entry"
UserForm1.Show
End Sub

For the button that edits an existing entry:-
Sub test2()
UserForm1.Caption = "Edit Entry"
UserForm1.Show
End Sub

When you run your code from the UserForm by clicking a button, use something
like
Private Sub CommandButton1_Click()
If UserForm1.Caption = "New Entry" Then
MsgBox "Code for new entry goes here"
Else
MsgBox "Code to edit existing entry goes here"
End If
End Sub

--
XL2002
Regards

William



"Steph" wrote in message
...
| Hi everyone. I created a pretty large userform. I then created 2 buttons
| on the Excel worksheet that calls the Userform- one for a New entry,
andone
| for an edit to an existing entry. The form has an "Enter" button that
| initates the writing to the database.
|
| The way I have it set up now, both buttons (edit and new) call the same
| userform. Ideally, I would like the following pseudo-code:
|
| If the New button is pushed, call Userform1, and when "Enter" is pushed
| write data entered to the bottom of the database,
|
| Else if Edit button is pushed, call Userform1, and when "Enter" is pushed
| write data back to the row that was edited.
|
| I don't know if this can be done without creating an entirely new
userform,
| or at least another "Enter" button. But I'd like to simply use the 1 form
| and 1 enter botton. Can you help?
|
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Writing data back via a userform

Is there a unique field in the database that uniquely identifies the record.

If so, then the simplest approach would be to check if the record being
entered exists or not. If it exists, update it. If not write it to the
bottom. then you would only need one button on your worksheet and one
userform.

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi everyone. I created a pretty large userform. I then created 2 buttons
on the Excel worksheet that calls the Userform- one for a New entry,

andone
for an edit to an existing entry. The form has an "Enter" button that
initates the writing to the database.

The way I have it set up now, both buttons (edit and new) call the same
userform. Ideally, I would like the following pseudo-code:

If the New button is pushed, call Userform1, and when "Enter" is pushed
write data entered to the bottom of the database,

Else if Edit button is pushed, call Userform1, and when "Enter" is pushed
write data back to the row that was edited.

I don't know if this can be done without creating an entirely new

userform,
or at least another "Enter" button. But I'd like to simply use the 1 form
and 1 enter botton. Can you help?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Writing data back via a userform

Thank you!!

"Tom Ogilvy" wrote in message
...
Is there a unique field in the database that uniquely identifies the

record.

If so, then the simplest approach would be to check if the record being
entered exists or not. If it exists, update it. If not write it to the
bottom. then you would only need one button on your worksheet and one
userform.

--
Regards,
Tom Ogilvy

"Steph" wrote in message
...
Hi everyone. I created a pretty large userform. I then created 2

buttons
on the Excel worksheet that calls the Userform- one for a New entry,

andone
for an edit to an existing entry. The form has an "Enter" button that
initates the writing to the database.

The way I have it set up now, both buttons (edit and new) call the same
userform. Ideally, I would like the following pseudo-code:

If the New button is pushed, call Userform1, and when "Enter" is pushed
write data entered to the bottom of the database,

Else if Edit button is pushed, call Userform1, and when "Enter" is

pushed
write data back to the row that was edited.

I don't know if this can be done without creating an entirely new

userform,
or at least another "Enter" button. But I'd like to simply use the 1

form
and 1 enter botton. Can you help?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a macro to bring back distinct value Sean[_7_] Excel Programming 2 May 24th 04 01:14 PM
Change focus from Userform back to Sheet rocketslinger[_2_] Excel Programming 5 January 11th 04 02:31 PM
Focus back from modeless userform to sheet RB Smissaert Excel Programming 4 September 5th 03 04:21 PM
Must be a way to force focus back to sheet instead of UserForm - isn't there? Les[_4_] Excel Programming 2 July 29th 03 12:45 PM
Userform Textbox writing to a cell Rich[_12_] Excel Programming 3 July 22nd 03 02:34 AM


All times are GMT +1. The time now is 03:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"