Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default enter data from a form to "found" fields

I use the following code to search for a value in a
column and then display the field values in text boxes on
the form. I need a command to save the changes made to
the field values in the text boxes back to those specific
fields. Please help!

Private Sub cmdSearch_Click()
Dim rng As Range
With Worksheets("Sheet1").Columns(1)
Set rng = .Find(what:=frmSearch.TextBox1.Text, _
After:=Range("A65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
If Not rng Is Nothing Then
With frmSearch
.TextBox2.Text = rng.Offset(0, 1).Value
.TextBox3.Text = rng.Offset(0, 2).Value
' and so forth
End With
Else
MsgBox frmSearch.TextBox1.Text & _
" was not found"
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default enter data from a form to "found" fields

Either store the rng you used or find it again as below (and reverse the
direction)

Private Sub cmdSearch_Click()
Dim rng As Range
With Worksheets("Sheet1").Columns(1)
Set rng = .Find(what:=frmSearch.TextBox1.Text, _
After:=Range("A65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
If Not rng Is Nothing Then
With frmSearch
rng.Offset(0, 1).Value = .TextBox2.Text
rng.Offset(0, 2).Value = .TextBox3.Text
' and so forth
End With
Else
MsgBox frmSearch.TextBox1.Text & _
" was not found"
End If
End Sub


--
Regards,
Tom Ogilvy

"Travis" wrote in message
...
I use the following code to search for a value in a
column and then display the field values in text boxes on
the form. I need a command to save the changes made to
the field values in the text boxes back to those specific
fields. Please help!

Private Sub cmdSearch_Click()
Dim rng As Range
With Worksheets("Sheet1").Columns(1)
Set rng = .Find(what:=frmSearch.TextBox1.Text, _
After:=Range("A65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
If Not rng Is Nothing Then
With frmSearch
.TextBox2.Text = rng.Offset(0, 1).Value
.TextBox3.Text = rng.Offset(0, 2).Value
' and so forth
End With
Else
MsgBox frmSearch.TextBox1.Text & _
" was not found"
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default enter data from a form to "found" fields

TOM,

Thank you 1,000 times over. I don't know how you learn
all of these nuances of excel and VBA, but I truly
appreciate it. Now I can finish my program and get it in
action next monday, thank you again for your input.

Travis
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
Drop-down list on simple excel 2003 form using "form" from data me S Beals Excel Discussion (Misc queries) 0 March 2nd 10 08:35 PM
Enter "if then" / logical into a already existing cells with form Indigo-JDJ Excel Discussion (Misc queries) 3 November 2nd 09 04:36 PM
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! [email protected] Excel Discussion (Misc queries) 3 January 5th 07 02:18 PM
ISNA VLOOKUP any data prefixed with a "C7" cannot be found? Mike Jenkins Excel Discussion (Misc queries) 6 December 13th 05 02:20 AM


All times are GMT +1. The time now is 10:39 PM.

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

About Us

"It's about Microsoft Excel"