Multi-column form

  • Thread starter Thread starter Jerry Crosby
  • Start date Start date
J

Jerry Crosby

Is it possible to create a form that presents data in columns (like in a
report)? For instance, if I have 30 records in a table, each with field
called [Name], can I make a form presenting it like this:

[NameRecord#1] [NameRecord#2] [NameRecord#3]
[NameRecord#4] [NameRecord#5] [NameRecord#6]

etc. (Whether or not it lists them accross, then down, or down, then across,
doesn't matter to me.)

Of course, my question isn't really "can I do it," but rather, "if I can do
it, how?"

Thanks in advance.

Jerry
 
Yes it can be done. I can think of two ways, as an unbound form, or a form
with 3 sub forms.

1) Create a UNBOUND form with 30 UNBOUND text boxes named something clever
like txtBox1, txtBox2, etc.

In the OnLoad event of the form you can open a recordset that returns the
records you want to deal with. Loop through the recordset assigning the
value in each record to the appropriate text box.

At this point your users will be able to edit these records (assuming that
you have the forms Allow Edits property set to yes), but you will have to
write additional code to write their changes back to the table. It is
probably best to write this code in the Click Event of a "Save" Command
button on the same form.

Here is an example (UNTESTED) of how to loop through a recordset and assign
the contents of the records to a text box on the form

strSql = "SELECT TOP 10 PeopleID, LastName "
& "FROM tblPeople " _
& "ORDER BY LastName "
i = 1
Set rs = New ADODB.Recordset
rs.Open strSql, CurrentProject.Connection
If Not rs.BOF Or Not rs.EOF Then
With rs
.MoveFirst
Do While Not .EOF AND i <=30
Me("txtBox" & i ).Value = !LastName
i = i + 1
.MoveNext
Loop
End With
rs.Close
Set rs = Nothing


2) Create an unbound form with 3 bound subforms. The bound subforms will
have to have be bound with sql queries that bring back only the subset of
the names that are appropriate for it's position in the main form. Since we
know nothing about your data or its structure I don't know what those
queries would look like, how they might perform, or how difficult it would
be to craft them. But, the end result would be an editable bound form that
would require little or no code.

Here is an example of one way to write the three queries to return the
first, second, and third group of ten people

SELECT TOP 10 PeopleID, LastName
FROM tblPeople
ORDER BY LastName

SELECT TOP 10 PeopleID, LastName
FROM tblPeople
WHERE PeopleID Not In (SELECT TOP 10 PeopleID FROM tblPeople ORDER BY
LastName)
ORDER BY LastName

SELECT TOP 10 PeopleID, LastName
FROM tblPeople
WHERE PeopleID Not In (SELECT TOP 20 PeopleID FROM tblPeople ORDER BY
LastName)
ORDER BY LastName

Good luck with your project.

Ron W

Jerry Crosby said:
Is it possible to create a form that presents data in columns (like in a
report)? For instance, if I have 30 records in a table, each with field
called [Name], can I make a form presenting it like this:

[NameRecord#1] [NameRecord#2] [NameRecord#3]
[NameRecord#4] [NameRecord#5] [NameRecord#6]

etc. (Whether or not it lists them accross, then down, or down, then across,
doesn't matter to me.)

Of course, my question isn't really "can I do it," but rather, "if I can do
it, how?"

Thanks in advance.

Jerry
 
Back
Top