public sub foo(sender as object, e as eventargs) handles textbox1.keydown 'if e.keys is keys.enter 'maybe validate patient id 'if valid update other fields 'if not valid tell the user somehow 'else do nothing end sub
Very basic answer, but I was thinking you might want to just set up a handler for that textbox.
Just create a subpublic sub foo(sender as object, e as eventargs) handles textbox1.keydown 'if e.keys is keys.enter 'maybe validate patient id 'if valid update other fields 'if not valid tell the user somehow 'else do nothing end sub
Really basic pseudo code there, but the handler could probably get you started.
Aside from that, what jmc said about where your data is coming from is also important, and it will determine how you actually retrieve the data within that little pseudo-coded function I showed you
Is that a table on your form (or contained in memory in your application) or a table in a database?
I see what you did I think. You used the form to select a datasource for that list box.
I recommend getting your database into your code in a way that is accessible by all of your code.
You should check out Project->Add New Data Source...
And use the object it creates to be able to access your data. This is probably the simplest way to do what you're trying to do.