Always Display Current Record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I need a way to always display the current record in a table from a form but
be able to select a different record.

For example, when the form opens I want record #1 to be visible. If I
navigate to record #2 I want it visible as well but be able to select a
different record.

Can this be done using Access?
 
Hello,

I need a way to always display the current record in a table from a form but
be able to select a different record.

For example, when the form opens I want record #1 to be visible. If I
navigate to record #2 I want it visible as well but be able to select a
different record.

Can this be done using Access?

Well, not as stated. Access has no "record numbers" - a Table is an
unordered heap of data. There IS no "record #1" or "record #2" in any
useful way.

If your Form is based on a sorted query, you can put VBA code in the
form's Load event:

Private Sub Form_Load(Cancel as Integer)
DoCmd.GoToRecord acForm, Me.Name, acLast
End Sub

to navigate to the "last" record as defined by the query's sort order.
This may or may not be the most recently entered record, depending on
how you define the sort!

John W. Vinson[MVP]
 
Hi Guys,

I figured out a solution for what I wanted to do. It required 3 things to
achieve the results I wanted. I'm working with a table named "Documents"
that's already been numbered sequentially 1, 2, 3 etc. by using the Make
Table query. In it are document numbers I want to display as the user
navigates through the table.

Here's what I needed:

1. Unbound Combo Box ( Query points to fields DocID, DocNumber)
2. Hidden Combo Box bound to table field "Documents"
3. Text Box bound to Hidden Combo Box

The Text Box displays the document number and description at the top of the
form as the user navigates to different records.

Unbound Combo box is used to hold document numbers by department like
"Admin, Clerical, Laboratory" so I created buttons to represent each
department. When a department button is clicked that record group is loaded
into Unbound Combo box with code as follows:

Private Sub btnAdmin_Click()
' Define query string
strSQL = "SELECT Dept.DeptID, Dept.[Document Number], Dept.[Document Title]
FROM Dept WHERE Dept.[Document Number] Like 'A-*';"
Forms!DocMatrix!cboDocNumers.RowSource = strSQL

' Fill ComboBox with courses chosen above
Me.cboDocNumers.Requery

' Force ComboBox to drop down
Me.cboDocNumers.SetFocus
Me.cboDocNumers.Dropdown

End Sub

Now, instead of a user having to scroll through hundreds of docs they can
scroll by department group. Also, they always know what the current record is
by looking at the text box at the top of the form window. I have code that
finds the selected records in Unbound Combo Box so everything now works great.

Thank you guys for replying. I hope this post can help others.

-Simon
 
Back
Top