473,385 Members | 1,521 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,385 software developers and data experts.

not able to navigate recordset

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 1335

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

Similar topics

27
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...
1
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...
1
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. ...
2
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...
2
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....
7
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...
1
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...
2
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...
16
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.