Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create an Unbound Form 1

Status
Not open for further replies.

ptuck

MIS
Aug 8, 2003
130
US
What are the steps to create an unbound form? I thinking this may help the speed of my DB, but not sure on how to get started. Maybe my question should be how do a create a record set for a unbound form?? I think I understand how to create the recordset, but the connection part is what I am confused on.
 
The definition of an unbound form is that it has absolutely no direct connection to any tables or queries. All controls have no ControlSource designation and the data is only saved to a table upon executing some VBA code from let's say behind a button. The recordset code is used at that time to update the data from forms controls to the specified table in the specific database.

Post back if you have more questions.

Code:
Dim db as DAO.Database
Dim rs as DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tablename", dbOpenDynaset)
rs.FindFirst "[ID] = " & Me![ID_control]
rs.AddNew
rs("fieldname1") = Me![field1_control]
. . .
rs.Update
rs.close
db.close

This example will give you a start on how to update a table using VBA code and a recordset.

[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
Thanks for the response and I do have couple more questions.

The tables and queries can be in the same database correct? Should I use ADO or DAO? I was thinking that ADO is the newest of the two.
 
One more...Can I use an SQL statement for the source instead of a table? Or can I use a query for a the source instead of a table?
 
ADO is the latest but DAO is still used by a lot of programmers. The recordsource of a form can be a table, query, or SQL string. The OpenRecordset command seen in the code above can be a table, query, or SQL string also.

What is your reason for wanting to use an unbound form? I have very rarely done this.



[COLOR=006633]Bob Scriver[/color]
MIState1.gif
[COLOR=white 006633]MSU Spartan[/color]
 
I am under the impression that it would improve performance. We have several users and the database is on a server. My thoughts was to split the database and use code to update. I have tried to let access split it but the performance was the same or worse. Any thoughts would be welcomed.
 
ptuck

Basing a form on a table or query or SQL (which the same thing) is still binding a form.

An unbound form would only run an action when the end user runs an event. For example, the user enters a customer number into a field - code retrieves the one cusomter record, or all open invoices for the customer. Or they click an "Add" button, enter their data into the prepared form and then submit / update the entry.

It is a bit of work, and takes a few tries to get a strategy that is user firendly, etc.

You can cheat, and have one or two or three forms bound to a table on the form. For example, a primary key and one or two highly searched fields. For example, the customer number.

ADO vs DAO???
No matter which you choose, others will agree and disagree.

DAO is older, and there is the occasional rumour that Microsoft may stop supporting it down the road. But there is a lot of good coding examples available. A preference, but DAO may be easier to use, and may have a better data definition language.

ADO is newer and much more flexible in how you connect to the database. Since ADO is enabled and ADO disabled on a default install of Access 2000 and above, I suspect it is safe to say that ADO is Mircosoft's perferred library.

(Okay, gerus's of coding -- shoot me!)

Richard
 
Thanks guys for all the advice....You all are great...
 
One of the biggest performance hogs in access is the "Track name autocorrect info" option.

This is found in Tools>Options>General.

Typically, what I do is keep this option selected when I am designing, but make sure that it is unchecked once the DB has been deployed.

I have always found that this makes a big difference to the speed of opening forms, especially if there are a lot of controls on the form.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top