473,408 Members | 2,477 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,408 software developers and data experts.

Unbound form, how to get to next record ?

Hello,

Well here goes, I am using Microsoft Access to design a user interface for SQL Server database, I am currntly using the project method. I have manged to link it up and get my form to show the record, but when I go to click on next record it is not showing the next record. Where you have the next buttons it shows how many records there are, in this instance there is 706, but always seems to get stuck on the first record, this is the code I have so far, have been searching the net and can not seem to find anything.

Here is my code:-
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load() 
  2.    Dim cn As ADODB.Connection 
  3.     Dim rs As ADODB.Recordset 
  4.  
  5.     Set cn = CurrentProject.AccessConnection 
  6.     Set rs = New ADODB.Recordset 
  7.         With rs 
  8.             Set .ActiveConnection = cn 
  9.             .Source = "SELECT * FROM prod_parent" 
  10.             .LockType = adLockOptimistic 
  11.             .CursorType = adOpenKeyset 
  12.             .Open 
  13.         End With 
  14.  
  15.    Set Me.Recordset = rs 
  16.  
  17.    Me.prodcode = rs!prodcode 
  18.    Me.prodtitl = rs!prodtitl 
  19.    Me.price = rs!price 
  20.    Me.description = rs!description 
  21.    rs.Close 
  22.    Set rs = Nothing 
  23.    Set cn = Nothing 
  24. End Sub
Thanks
Aug 18 '09 #1
3 5643
ADezii
8,834 Expert 8TB
@mbilalk
The simplest possible explanation, not accounting for EOF and other factors:
  1. Delare the Connection and Recordset Variables in the Form's Code Module:
    Expand|Select|Wrap|Line Numbers
    1. Private cn As ADODB.Connection
    2. Private rs As ADODB.Recordset
  2. Create the Recordset and populate the Form with the 1st Record in the Load() Event of the Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Load()
    2. Set cn = CurrentProject.Connection
    3. Set rs = New ADODB.Recordset
    4.  
    5. With rs
    6.   Set .ActiveConnection = cn
    7.  .Source = "SELECT * FROM prod_parent"
    8.  .LockType = adLockOptimistic
    9.  .CursorType = adOpenKeyset
    10.    .Open
    11. End With
    12.  
    13. Set Me.Recordset = rs
    14.  
    15. Me.prodcode = rs!prodcode
    16. Me.prodtitl = rs!prodtitl
    17. Me.price = rs!price
    18. Me.Description = rs!Description
    19. End Sub
  3. To Move to the Next Record in the Recordset and display the Record on the Form:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdNextRecord_Click()
    2. Me.Recordset.MoveNext
    3.  
    4. Me.prodcode = rs!prodcode
    5. Me.prodtitl = rs!prodtitl
    6. Me.price = rs!price
    7. Me.Description = rs!Description
    8. End Sub
  4. To Close the Recordset and Connection and regain memory:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Close()
    2. rs.Close
    3. cn.Close
    4. Set rs = Nothing
    5. End Sub
Aug 18 '09 #2
Hi ADezii,
Thanks a lot for ur reply. I was looking for the exact soltion which you provided. Now i am on motor way and enjoying programming.

once again Thanks a lot.
Aug 19 '09 #3
ADezii
8,834 Expert 8TB
@mbilalk
You are quite welcome.
Aug 19 '09 #4

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...
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: MLH | last post by:
I have a form, bound to a query. Its RecordSource property is a query named frmEnterLienAmounts. The form has a few bound controls and some unbound controls. The unbound controls are calculated...
4
by: Robert | last post by:
Have main form with an unbound subform1 which is used for data entry. Subform1 has a nested continuous unbound subform (subform2) which is used to enter multiple records related to the record being...
20
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of...
10
by: Matthew Wells | last post by:
Hello. I've converted a bound Access 2000 form which displays data retrieved from an Access 2000 database to an unbound form. Now my hyperlinks don't work. I'm assuming it's because the form...
1
by: planetthoughtful | last post by:
Hi All, I have a mainform with a subform in which I show some task summary data. On the mainform I have a number of unbound controls that reflect values relevant to each task in the subform....
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
6
by: Greg Strong | last post by:
Hello All, Is is possible to use an ADO recordset to populate an unbound continuous Subform? I've done some Googling without much luck, so this maybe impossible, but let me try to explain...
11
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.