LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,670
Default Code Review

Hello all, I got some fantastic help on this problem yesterday and wanted to
see if someone could take a look at my code and possibly offer some
suggestions.

What I have is a sheet that users access to pull up customer information
from another sheet. This code is attached to a form with a ComboBox
(ComboBox1) and 3 TextBoxes (1,2,3) that will eventually allow the users to
locate and change customer info. This code locates and fills in the
TextBoxes' information based upon the record displayed in The ComboBox. I can
change the information in the TextBoxes, but the new info added right now
only changes for TextBox1. Once I place the focus back onto ComboBox1, the
information reverts back to what was originally there. Now that I've confused
everyone, here's the code. TextBoxes 2 & 3 are not updating the sheet with
the new info. Any Thoughts?

Private Sub ComboBox1_Change()

Dim res As Variant
Set ws1 = Worksheets("Customer Database")
ws1.Activate
With ws1
res = Application.Match(ComboBox1.Value, Range("A:A"), 0)
If IsError(res) Then
MsgBox ComboBox1.Value & " Not Found"
Else
For i = 1 To 3
Me.Controls("TextBox" & i) = .Cells(res, i + 1)
Next i
End If
End With
End Sub

Private Sub CommandButton1_Click()

Dim res As Variant
Set ws1 = Worksheets("Customer Database")
ws1.Activate
With ws1
res = Application.Match(ComboBox1.Value, Range("A:A"), 0)
If IsError(res) Then
MsgBox ComboBox1.Value & " Not Found"
Else
For i = 1 To 3
If Me.Controls("TextBox" & i) < "" Then .Cells(res, i + 1) =
Me.Controls("TextBox" & i).Value
Next i
End If
End With
End Sub

Any help would be appreciated! Thanks!!
 
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
Months of review Pasty Excel Worksheet Functions 7 November 13th 06 05:17 PM
vba code to block review toolbar Todd F Excel Programming 7 October 16th 06 12:23 AM
Change the interior color of a cell - Code Review Tiny Tim Excel Programming 6 December 17th 05 09:49 PM
code that might be causing error - please review and comment bruce forster Excel Programming 4 May 21st 04 03:06 AM
VB6 with Excel Objects: Please review my code Kurt Remlin Excel Programming 6 May 1st 04 03:36 AM


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