Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default A Userform goodie - updating records

I am almost getting to the end of my project! I have a series of userforms
collecting and writing data to an excel spreadsheet, my struggle now is how I
could give users the option to amend a particular record. I can search for
records by a unique reference each one has, but how can I then pull this
information back into the appropriate userform so the user can made an
amendment to that particular record?

Any pointers in the right direction gratefully received!

--
Zani
(if I have posted here, I really am stuck!)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default A Userform goodie - updating records

If it's set up as I think you describe (a spreadsheet containing all
the info for a record number along that same row), then simply reverse
the process.

When you write the data to the user form, you've probably got a button
that runs a macro to transfer the data to the cells from your textboxes
such as

Sheets("Data").Cells(14,37).Value = UserForm1.TextBox1.Text (or
similar).

To get the data back to the userform, just reverse the statement and
place it in a suitable event module:

UserForm1.TextBox1.Text = Sheets("Data").Cells(14,37).Value

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default A Userform goodie - updating records

Thank you so much for that - I can't believe it was as easy as that - works
fantastically for all the textboxes and optionsbuttons. Here comes the
tricky bit though - on this userform there are 3 listboxes the first being
the main one, and then two and three have values dependent on the value of
the first and then the second.

I can get my list box entries back into my userform, but then how can I
highlight what the selected option was when the original data was stored?


--
Zani
(if I have posted here, I really am stuck!)



"JakeyC" wrote:

If it's set up as I think you describe (a spreadsheet containing all
the info for a record number along that same row), then simply reverse
the process.

When you write the data to the user form, you've probably got a button
that runs a macro to transfer the data to the cells from your textboxes
such as

Sheets("Data").Cells(14,37).Value = UserForm1.TextBox1.Text (or
similar).

To get the data back to the userform, just reverse the statement and
place it in a suitable event module:

UserForm1.TextBox1.Text = Sheets("Data").Cells(14,37).Value


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default A Userform goodie - updating records

I also have a slight problem returning times from the data in the spreadsheet
back to the userform - they show as numbers rather than the original 24 hr
clock.
--
Zani
(if I have posted here, I really am stuck!)



"JakeyC" wrote:

If it's set up as I think you describe (a spreadsheet containing all
the info for a record number along that same row), then simply reverse
the process.

When you write the data to the user form, you've probably got a button
that runs a macro to transfer the data to the cells from your textboxes
such as

Sheets("Data").Cells(14,37).Value = UserForm1.TextBox1.Text (or
similar).

To get the data back to the userform, just reverse the statement and
place it in a suitable event module:

UserForm1.TextBox1.Text = Sheets("Data").Cells(14,37).Value


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default A Userform goodie - updating records

Zani,
You can use FORMAT to get the data correct. In the xample below, I
ssume Range("A1") to contain time in format hh:mm e.g. 12:30 in textbox

Private Sub UserForm_Initialize()
TextBox1.Value = Format(ThisWorkbook.Sheets("Sheet1").Range("a1"), "HH:MM")
End Sub

I I understand your requirement about positioning the listox(es), you could
store the value of LISTINDEX for each box and in the UserForm_Initialize
module set LISTINDEX to stored value.

Private Sub UserForm_Initialize()
TextBox1.Value = Format(ThisWorkbook.Sheets("Sheet1").Range("a1"), "HH:MM")
ListBox1.ListIndex = Range("C1") <=== Set ListIndex
End Sub

Private Sub ListBox1_Click()
Range("C1") = ListBox1.ListIndex <== Saved in C1
End Sub

HTH

"Zani" wrote:

I also have a slight problem returning times from the data in the spreadsheet
back to the userform - they show as numbers rather than the original 24 hr
clock.
--
Zani
(if I have posted here, I really am stuck!)



"JakeyC" wrote:

If it's set up as I think you describe (a spreadsheet containing all
the info for a record number along that same row), then simply reverse
the process.

When you write the data to the user form, you've probably got a button
that runs a macro to transfer the data to the cells from your textboxes
such as

Sheets("Data").Cells(14,37).Value = UserForm1.TextBox1.Text (or
similar).

To get the data back to the userform, just reverse the statement and
place it in a suitable event module:

UserForm1.TextBox1.Text = Sheets("Data").Cells(14,37).Value




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default A Userform goodie - updating records

To select an entry in the listbox, use something like:

ListBox1.Value = Range("B1").Value 'where B1 is the cell you stored the
previous selection in. This might activate the Click event so turn
Events off if need be with Application.EnableEvents = False.

As for the dates, the only workaround I can think of is to store them
as text format in the destination cells.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default A Userform goodie - updating records

Thanks I'll give them a go!
--
Zani
(if I have posted here, I really am stuck!)



"JakeyC" wrote:

To select an entry in the listbox, use something like:

ListBox1.Value = Range("B1").Value 'where B1 is the cell you stored the
previous selection in. This might activate the Click event so turn
Events off if need be with Application.EnableEvents = False.

As for the dates, the only workaround I can think of is to store them
as text format in the destination cells.


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
Updating & Archiving Records sandy Excel Worksheet Functions 4 June 11th 09 05:43 PM
userform for updating records Terry Excel Discussion (Misc queries) 2 August 27th 08 04:16 PM
Updating old records law Excel Discussion (Misc queries) 0 December 2nd 07 03:01 PM
Updating Master Log records Sinner Excel Worksheet Functions 7 June 18th 07 01:39 PM
Updating records in another workbook BKKRick Excel Programming 0 October 3rd 04 02:09 PM


All times are GMT +1. The time now is 11:04 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"