473,785 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not able to navigate recordset

20 New Member
Hi, I am new VB programming in Access and I am requesting help with the following code.

This code is attached to a form that will display a specific recordset based in information passed to the form from another form. The problem I am having is that for each of the case statements the proper records (values and Number of records) are being returned but the movement commands do not work, only the first record in the set is displayed. I can use the troubleshooting code to advance the recordset to any point in the file at which the display is blank until I click the cmdMoveFirst button. I’m missing something. I don’t think it is the code for the nav buttons thats' pretty simple stuff. From what research I’ve done I think/suspect, but mostly guess it’s the cursor type and location. Any help would be greatly appreciated, especially tips on trouble shooting this type of problem.

TIA

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub Form_Load()
  4.  
  5. Dim SQL As String
  6. Dim cmdFormPop As ADODB.Command
  7. Dim cnn As ADODB.Connection
  8. Dim fldUserAssignment As ADODB.Field
  9. 'Dim prmValue1 As ADODB.Parameter
  10. Dim S1 As Integer
  11.  
  12.  
  13.     Set cmdFormPop = New Command
  14.     Set cmdFormPop.ActiveConnection = CurrentProject.Connection
  15.  
  16.  
  17.     S1 = gUserAssignment  'pass user ID to parameter value
  18.  
  19.     Debug.Print gFormState
  20.  
  21.     With gRS
  22.         .CursorType = adOpenDynamic
  23.         .CursorLocation = adUseServer
  24.         .LockType = adLockBatchOptimistic
  25.     End With
  26.  
  27.     Select Case gFormState
  28.  
  29.     Case "Unworked"
  30.  
  31.  
  32.         cmdFormPop.CommandType = adCmdText
  33.         cmdFormPop.CommandText = "SELECT CLAMNO,VENDNM,Question1 FROM PPmaster " & _
  34.             "WHERE ((PPmaster.UserAssignment) = ? And (PPmaster.Question1) = 1);"
  35.  
  36.         Set prm0 = cmdFormPop.CreateParameter("prmUserAssignment", adVarChar, adParamInput, 15)
  37.         prm0.Value = S1
  38.  
  39.         cmdFormPop.Parameters.Append prm0
  40.  
  41.         Set gRS = cmdFormPop.Execute
  42.  
  43.  
  44.     Case "Worked"
  45.  
  46.         cmdFormPop.CommandType = adCmdText
  47.         cmdFormPop.CommandText = "SELECT CLAMNO,VENDNM,Question1 FROM PPmaster " & _
  48.             "WHERE ((PPmaster.UserAssignment) = ? And (PPmaster.Question1) <> 1);"
  49.  
  50.         Set prm0 = cmdFormPop.CreateParameter("prmUserAssignment", adVarChar, adParamInput, 15)
  51.         prm0.Value = S1
  52.  
  53.         cmdFormPop.Parameters.Append prm0
  54.  
  55.         Set gRS = cmdFormPop.Execute
  56.  
  57.  
  58.     Case "All"
  59.  
  60.         cmdFormPop.CommandType = adCmdText
  61.         cmdFormPop.CommandText = "SELECT CLAMNO,VENDNM,Question1 FROM PPmaster " & _
  62.             "WHERE (PPmaster.UserAssignment) = ?;"
  63.  
  64.         Set prm0 = cmdFormPop.CreateParameter("prmUserAssignment", adVarChar, adParamInput, 15)
  65.         prm0.Value = S1
  66.  
  67.         cmdFormPop.Parameters.Append prm0
  68.  
  69.         Set gRS = cmdFormPop.Execute
  70.  
  71.     End Select
  72.  
  73.  
  74.     'troulbe shooting code to validatecorrect records are returned
  75.  
  76.     Do Until gRS.EOF
  77.         Debug.Print gRS.Fields(0)
  78.         Debug.Print gRS.Fields(1)
  79.         Debug.Print gRS.Fields(2)
  80.                 gRS.MoveNext
  81.     Loop
  82.  
  83.             Debug.Print "record count: "; gRS.RecordCount
  84.  
  85.  
  86.     gRS.MoveFirst
  87.  
  88.     'MasterDisplay is a seperate module that will dispaly all of
  89.     'the fields in a single instance instead of under each move control
  90.  
  91.     'MasterDisplay
  92.  
  93.  
  94. End Sub
  95. Public Sub cmdMoveFirst_Click()
  96.  
  97.     On Error GoTo DbError
  98.  
  99.     'Move to the first record in the result set.
  100.     gRS.MoveFirst
  101.  
  102.         Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
  103.         Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
  104.         Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
  105.  
  106.  
  107.         'MasterDisplay is a seperate module that will dispaly all of
  108.             'the fields in a single instance instead of under each move control
  109.  
  110.         'MasterDisplay
  111.  
  112.     Exit Sub
  113.  
  114. DbError:
  115.  
  116.     MsgBox "There was an error retrieving information " & _
  117.         "from the database." _
  118.         & Err.Number & ", " & Err.Description
  119.  
  120. End Sub
  121.  
  122. Public Sub cmdMoveLast_Click()
  123.  
  124.     On Error GoTo DbError
  125.  
  126.     'Move to the last record in the result set.
  127.     gRS.MoveLast
  128.  
  129.         Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
  130.         Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
  131.         Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
  132.  
  133.  
  134.         'MasterDisplay is a seperate module that will dispaly all of
  135.             'the fields in a single instance instead of under each move control
  136.  
  137.         'MasterDisplay
  138.  
  139.     Exit Sub
  140.  
  141. DbError:
  142.  
  143.     MsgBox "There was an error retrieving information " & _
  144.         "from the database." _
  145.         & Err.Number & ", " & Err.Description
  146.  
  147. End Sub
  148.  
  149. Public Sub cmdMoveNext_Click()
  150.  
  151.     On Error GoTo DbError
  152.     'Move to the next record in the result set if the cursor is not
  153.     'already at the last record.
  154.     If gRS.AbsolutePosition < _
  155.         gRS.RecordCount Then
  156.  
  157.         gRS.MoveNext
  158.  
  159.         Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
  160.         Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
  161.         Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
  162.  
  163.  
  164.         'MasterDisplay is a seperate module that will dispaly all of
  165.             'the fields in a single instance instead of under each move control
  166.  
  167.         'MasterDisplay
  168.  
  169.  
  170.     End If
  171.  
  172.     Exit Sub
  173.  
  174. DbError:
  175.  
  176.     MsgBox "There was an error retrieving information " & _
  177.         "from the database." _
  178.         & Err.Number & ", " & Err.Description
  179.  
  180. End Sub
  181.  
  182. Public Sub cmdMovePrevious_Click()
  183.  
  184.     On Error GoTo DbError
  185.  
  186.     'Move to the previous record in the result set, if the
  187.     'current record is not the first record.
  188.     If gRS.AbsolutePosition > 1 Then
  189.  
  190.         gRS.MovePrevious
  191.  
  192.         Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
  193.         Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
  194.         Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
  195.  
  196.  
  197.         'MasterDisplay is a seperate module that will dispaly all of
  198.             'the fields in a single instance instead of under each move control
  199.  
  200.         'MasterDisplay
  201.  
  202.     End If
  203.     Exit Sub
  204.  
  205. DbError:
  206.  
  207.     MsgBox "There was an error retrieving information " & _
  208.         "from the database." _
  209.         & Err.Number & ", " & Err.Description
  210.  
  211. End Sub
Aug 30 '07 #1
0 1355

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

Similar topics

27
6213
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is done? regards, Oscar
1
5303
by: Joe Bond | last post by:
Hi. I have a simple MS Access 2000 form in which I enter some customer data. When the address field is entered I need to see if a duplicate record exists. I need to know this *right away* before the remaining fields are filled out, so I'm trying to call a function on the Address_LostFocus() event which will do the lookup. If a match is found, it should prompt the user to either continue, or navigate to the existing record. This is where...
1
2194
by: ano1optimist | last post by:
Has anyone had success with using a command collection with parameters to run a stored procedure from sql server? I'm frustrated and have been spending way too much time trying to make this work. If you have a code sample, I'd love it. I've posted the code in a previous post but didn't have any responses as to what was occurring so I'm going to try once more. I have a connection to SQL 7 and use a command collection with one...
2
8610
by: corepaul | last post by:
I am fairly new to Access and I have a problem trying to use bookmarks with a recordset. I have a recordset dimensioned as, Dim rstFoodDesc As ADODB.Recordset ' recordset Dim bMark As Variant ' variable to store bookmark I open the recordset with the statements,
2
3048
by: barret bonden | last post by:
(closest newsgroup I could find) Error Type: ADODB.Recordset (0x800A0CB3) Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype. /asp_data3_add.asp, line 30 <% 'Dimension variables Dim adoCon 'Holds the Database Connection Object
7
8370
by: marmottedodue | last post by:
Hello, I'm trying to debug an access project in which two kind of recordset are used: ADODB.recordset and DAO.recordset. I'm trying to set the whole project on DAO.recordset, but the following function does not work: Public Function GetRecordset(pstrCmdTxt As String, Optional pintCursorType As CursorTypeEnum = adOpenStatic) As Recordset ' was ADODB.recordset
1
2512
by: praveen79hebbar | last post by:
Hi, I have written a code to navigate through the recordset using MoveFirst,Movenext,MovePrevious and MoveLast i would like to fetch the records from the database and display it on a form in the textboxes.When i try to move from one record to another using MoveNext command it moves directly to the last record Here is the code Dim cn1 As ADODB.Connection Dim rs1 As ADODB.Recordset
2
4756
by: =?Utf-8?B?QmVybmFyZCBLaW0=?= | last post by:
I have VC# 2005. I need to use ADODB instead with ADO.NET. I can open a recordset. however, I can not navigate records in recordset. How can I navigate records? What is the command line for adorecordset.movenext, adorecordset,movefirst...etc. Please help me out.
16
2595
by: haft | last post by:
I have posted this question on a javascript forum as it contains javascript code however it was believed to be an asp issue. The following head section javascript code contains the function showBigImage( isource,bigImage,header ) function call of discussion: var currentImage; function showBigImage( isource,bigImage,header ) { var theImage = document.getElementById( 'largeimage' ); theImage.src = isource;
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10151
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.