I am trying to create a form that updates a record in a table.
This is very easy to accomplish if using navigation buttons, but I would
like to "jump" to the record I want to update by making a selection in a
list box. This box would list a "title" field from all records in the
table.
Any ideas? Thank you in advance...
The above is easy to solve, but I am confused by the issue of updating a
record..and how that is related to finding, and display a records in a list
box, and then going to that record? (how are the two questions
related?...they have little, or not relation to each other).
If you simply close a form, the record is saved. So, there is no need for
navigation buttons to save a record..and there never was a need for this
(perhaps this explains your confusing here??). Just put a close button on
the form for the user to exit (that is all they will want to do when done
since no navigation is going to take place).
As for displaying a list of matches in a form, you can send the results of a
search to a listbox..or often I use a continuous form. And, I would say 90%
or more of my forms DO NOT have navigation buttons (the user gets a form
with ONE record to edit, and when they are done..they close the form...and
are back to the search screen ready to do battle with the next customer (or
task).
I have some screen shots of grids..and most are screens of searching screens
where I present a list of names..and when you click on the list..the
approaocate record is displayed.
Take a look at the following screens to get some ideas:
http://www.members.shaw.ca/AlbertKallal/Articles/Grid.htm
and, some more here:
http://www.members.shaw.ca/AlbertKallal/Search/index.html
If we had a text box that you type in the first few characters of the
company name, and then hit enter key...we could then fill a listbox with all
companies that start with text typed in. The code to fill the listbox with
matches from the text box would be:
We would use the after update event of the text box
dim strSql as string
dim strWhere as string
strSql = "select id, CompanyName, City from tblCustomers"
strWhere = "CompanyName like '" & me.txtSearchBox & "*'"
me.MListBox.RowSouce = strSql & " where " & strWhere
The above would thus fill our lisbox (a 3 column listbox in our example)
with the search.
Now, to open up a form to a particular record from the list box, we would
have the user double click on any match in the list box.
So, the code behind the double click event of the listbox would be
docmd.OpenForm "frmCustomer",,,"id = " & me.listbox
You can see that VERY little code is needed here.
The above code is how those screen shots works