Adding a Next Record button to UserForm

E

excelnut1954

I have a button on a worksheet that the user can click when he wants to
find a record within the list. A userform comes up, asking for a PO# .
I have the code run a simple Cell.Find with the worksheet (Current
List).

In a crude way, I have it go to each field of that record, and populate
all the textboxes in a second userform . Works fine. Very simple.

However, I would like to also use this userform in another worksheet
(Deleted List) that will contain these same records that are put there
when the material (PO) is taken from the warehouse (and off the Current
List).

For the purpose of this userform, the difference in the 2 worksheets
is that the Current List will not contain duplicate lines with the same
PO#, while the Deleted List will have many duplicates. (Many times,
material will come in at different times from the same PO. And, parts
of a PO will leave the warehouse before the rest will.)

What I would like to do is to put a Next Record button on the userform
that shows all the fields of the record. Clicking the button would have
the next record populate in all the textboxes, just as it did with the
1st record.

Also, maybe a textbox that would contain a Y if there is another
record to look at. The user could then click the Next Record button if
there was a Y in that box. Over and over looking at each of the records
with the same PO# , until the Y is not in the box.
OR,
I suppose a better, but I'm sure a more complicated method would be
to have the button shaded when there is no other record found, and
active when there is more.

Anybody have something I could use? I've been looking at a good
number of places, but haven't found any examples that resemble what
I'm trying to do.

Hope I've made this clear enough. Sometime I make it more complicated
than it is.....
Thanks
J.O.
 
E

excelnut1954

After looking at the example for FindNext in VBA Help, I'm thinking I
should find a way to have the macro 1st find each PO on the list, based
on the user's request in the 1st userform.

This is what I have in the userform code , for when the user gives the
PO he wants to find.

Private Sub TextBox1_Change()

FindPOVal = TextBox1.Value
End Sub

I'm thinking that the macro needs to then go through the list, and give
a variable name to each of the records with that PO# found. Would that
work? Would the variable names given to each record be distinct to each
other, even though the PO numbers will be exactly the same? That is,
PO# 112 on line 10 on the list given variable name A
PO# 112 on line 20 on the list given variable name B
Would any code that references variable B cause it to only look at the
PO on line 20? And, not the same PO# on line 10? OR, would the
variable be given to the whole line for each record?
Thanks,
J.O.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top