473,396 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Populate An Unbound Form with Recordset

194 100+
Hello Everybody,

Please tell me is there any way to populate an unbound form of MS Access 2002 with Recordset of an MS Access 2002 external database??

if yes then how???

I dont wana link tables/queries what i want is to hold all data in recordset and then display it into the form like continuous forms.

thank u.
Nov 22 '07 #1
2 18587
FishVal
2,653 Expert 2GB
Hi, where.

You may try to use Form.Recordset property.
The following code bind an unbound form to table [t1] located in the same db.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.     Set Me.Recordset = CurrentDb.OpenRecordset("SELECT * FROM t1;")
  3. End Sub
  4.  
P.S. Sure, forms controls are expected to have right values in ControlSourcce property.
Nov 22 '07 #2
ADezii
8,834 Expert 8TB
Hello Everybody,

Please tell me is there any way to populate an unbound form of MS Access 2002 with Recordset of an MS Access 2002 external database??

if yes then how???

I dont wana link tables/queries what i want is to hold all data in recordset and then display it into the form like continuous forms.

thank u.
Let's assume you wish to populate an Unbound Access Form consisting of three Unbound Text Boxes named txtFirstName, txtLastName, and txtBirthDate. Furthermore, the mechanism with which you wish to populate this Form is via a Recordset created on an External Database. In this scenario, the External Database is Northwind.mdb residing in the C:\Test\ Directory. We will use the Employees Table as the source of the Recordset and populate our Unbound Access Form and Text Boxes with 3 Fields from this Recordset. Follow these 3 simple steps:
  1. Place the following Declarations in the Form's Code Module (Declarations Section):
    Expand|Select|Wrap|Line Numbers
    1. Dim wrkJet As Workspace
    2. Dim dbsNorthwind As DAO.Database, rstNorthWind As DAO.Recordset
  2. Copy and Paste the following code to the Open() Event of the Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Open(Cancel As Integer)
    2. 'Create Microsoft Jet Workspace object.
    3. Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
    4.  
    5. 'Open Database object from saved Microsoft Jet database for exclusive use
    6. Set dbsNorthwind = wrkJet.OpenDatabase("C:\Test\Northwind.mdb", True)
    7.  
    8. Set rstNorthWind = dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)
    9.  
    10. Set Me.Recordset = rstNorthWind
    11.  
    12. Me![txtFirstName].ControlSource = "FirstName"
    13. Me![txtLastName].ControlSource = "LastName"
    14. Me![txtBirthDate].ControlSource = "BirthDate"
    15. End Sub
  3. Place the following code in the Close() Event of the Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Close()
    2.   rstNorthWind.Close
    3.   Set rstNorthWind = Nothing
    4. End Sub
  4. This code has been tested and is fully operational, let me know how you make out.
Nov 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim Marshall | last post by:
This is an embarrassing question to which I should know the answer, but I am not 100% sure of myself. My applications, whether they are Jet or Oracle usually deal with reporting on existing apps...
2
by: ano1optimist | last post by:
I have a form with a search button. I'm using command parameters to pass search criteria to a stored procedure. Here is my code: Stored procedure: CREATE PROCEDURE . @strCriteria varchar(200)...
1
by: huela | last post by:
Somehow i have to display the recordset in unbound form When i use the following display the data in recordset to unbound form. I have a question: i can only display the last record data, all...
4
by: Pierre | last post by:
Hi all, To ease load on a network i close automatically form open with a timer reset by user actions. If the time is expired i go through the collections of form and table and close all those...
3
by: Stig | last post by:
Hi, Any help on this one will be greatly appreciated as I have spent too long banging my head against the screen trying to get it sorted. Basically I would like to have a select all records...
0
by: ndindi22 | last post by:
HI guys, How do I Add/ Edit/ Delete using Unbound MS Access .adp Project/ VBA Form I need to populate the form manually by executing SQL statements in the VBA code. Add buttons to the form to...
6
by: Volker Neurath | last post by:
Hi all, I have a Problem with combobox-property "NotInList" and an unbound Form. The situation: On my main form i have three comboboxes for data-exchange (here: Names of distributor,...
8
patjones
by: patjones | last post by:
Hi: There are many posts both here and on other forums about this topic, but nothing quite matching what I have... I have an unbound form called frmChecks which displays information by means of...
7
by: troy_lee | last post by:
I have an unbound form. I have an Add New procedure that saves a new record to the database. What is the best way to update an existing record? In other words, clicking my "Submit record" button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.