Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filling Text Boxes from table data

Status
Not open for further replies.

NewProg

Programmer
Oct 18, 2002
3
0
0
US
I'm new to VBA. I have a form where the user inputs a part
number and I want the description to pop up in the text box if the part has been entered before. I have used Visual Basic and done this but I'm having a real problem with VBA.
In VB I had a command button that searched and filled the text box. Can I use that here? Do I need to use a function? My SQL statements are getting errors and I'm really lost. Any help would be appreciated.
 
I can maybe do what you ask if it's in a worksheet, my SQL skills are very rusty, but maybe someone could "do something" with it...

Private Sub BtnFind_Click()
Dim MyVar as Object
Set MyVar = Sheets("Sheet2").Cells

Dim Row As Integer
Row = 2
While Not IsEmpty(MyVar(Row, 1)) And MyVar(Row, 1) <> TextCode
Row = Row + 1
Wend
If IsEmpty(MyVar(Row, 1)) Then
MsgBox &quot;Quote Code Not Found&quot;
TextCode.SetFocus
Else
TextName = MyVar(Row, 2)
End If
End Sub

... what that does: as soon as you enter a string, hit the button and it searches Sheet 3 (column 1, change the &quot;row&quot; values for different columns) for that string. If it is found, it prints the cell to the right of that (column 2, change the &quot;row&quot; variable also) into another textbox. Put this code in TextCode_Change() so it will update real-time.

Sorry if I'm talking crap, I just remembered I had that and thought maybe it could help a little.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top