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 -
Option Compare Database
-
-
Private Sub Form_Load()
-
-
Dim SQL As String
-
Dim cmdFormPop As ADODB.Command
-
Dim cnn As ADODB.Connection
-
Dim fldUserAssignment As ADODB.Field
-
'Dim prmValue1 As ADODB.Parameter
-
Dim S1 As Integer
-
-
-
Set cmdFormPop = New Command
-
Set cmdFormPop.ActiveConnection = CurrentProject.Connection
-
-
-
S1 = gUserAssignment 'pass user ID to parameter value
-
-
Debug.Print gFormState
-
-
With gRS
-
.CursorType = adOpenDynamic
-
.CursorLocation = adUseServer
-
.LockType = adLockBatchOptimistic
-
End With
-
-
Select Case gFormState
-
-
Case "Unworked"
-
-
-
cmdFormPop.CommandType = adCmdText
-
cmdFormPop.CommandText = "SELECT CLAMNO,VENDNM,Question1 FROM PPmaster " & _
-
"WHERE ((PPmaster.UserAssignment) = ? And (PPmaster.Question1) = 1);"
-
-
Set prm0 = cmdFormPop.CreateParameter("prmUserAssignment", adVarChar, adParamInput, 15)
-
prm0.Value = S1
-
-
cmdFormPop.Parameters.Append prm0
-
-
Set gRS = cmdFormPop.Execute
-
-
-
Case "Worked"
-
-
cmdFormPop.CommandType = adCmdText
-
cmdFormPop.CommandText = "SELECT CLAMNO,VENDNM,Question1 FROM PPmaster " & _
-
"WHERE ((PPmaster.UserAssignment) = ? And (PPmaster.Question1) <> 1);"
-
-
Set prm0 = cmdFormPop.CreateParameter("prmUserAssignment", adVarChar, adParamInput, 15)
-
prm0.Value = S1
-
-
cmdFormPop.Parameters.Append prm0
-
-
Set gRS = cmdFormPop.Execute
-
-
-
Case "All"
-
-
cmdFormPop.CommandType = adCmdText
-
cmdFormPop.CommandText = "SELECT CLAMNO,VENDNM,Question1 FROM PPmaster " & _
-
"WHERE (PPmaster.UserAssignment) = ?;"
-
-
Set prm0 = cmdFormPop.CreateParameter("prmUserAssignment", adVarChar, adParamInput, 15)
-
prm0.Value = S1
-
-
cmdFormPop.Parameters.Append prm0
-
-
Set gRS = cmdFormPop.Execute
-
-
End Select
-
-
-
'troulbe shooting code to validatecorrect records are returned
-
-
Do Until gRS.EOF
-
Debug.Print gRS.Fields(0)
-
Debug.Print gRS.Fields(1)
-
Debug.Print gRS.Fields(2)
-
gRS.MoveNext
-
Loop
-
-
Debug.Print "record count: "; gRS.RecordCount
-
-
-
gRS.MoveFirst
-
-
'MasterDisplay is a seperate module that will dispaly all of
-
'the fields in a single instance instead of under each move control
-
-
'MasterDisplay
-
-
-
End Sub
-
Public Sub cmdMoveFirst_Click()
-
-
On Error GoTo DbError
-
-
'Move to the first record in the result set.
-
gRS.MoveFirst
-
-
Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
-
Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
-
Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
-
-
-
'MasterDisplay is a seperate module that will dispaly all of
-
'the fields in a single instance instead of under each move control
-
-
'MasterDisplay
-
-
Exit Sub
-
-
DbError:
-
-
MsgBox "There was an error retrieving information " & _
-
"from the database." _
-
& Err.Number & ", " & Err.Description
-
-
End Sub
-
-
Public Sub cmdMoveLast_Click()
-
-
On Error GoTo DbError
-
-
'Move to the last record in the result set.
-
gRS.MoveLast
-
-
Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
-
Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
-
Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
-
-
-
'MasterDisplay is a seperate module that will dispaly all of
-
'the fields in a single instance instead of under each move control
-
-
'MasterDisplay
-
-
Exit Sub
-
-
DbError:
-
-
MsgBox "There was an error retrieving information " & _
-
"from the database." _
-
& Err.Number & ", " & Err.Description
-
-
End Sub
-
-
Public Sub cmdMoveNext_Click()
-
-
On Error GoTo DbError
-
'Move to the next record in the result set if the cursor is not
-
'already at the last record.
-
If gRS.AbsolutePosition < _
-
gRS.RecordCount Then
-
-
gRS.MoveNext
-
-
Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
-
Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
-
Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
-
-
-
'MasterDisplay is a seperate module that will dispaly all of
-
'the fields in a single instance instead of under each move control
-
-
'MasterDisplay
-
-
-
End If
-
-
Exit Sub
-
-
DbError:
-
-
MsgBox "There was an error retrieving information " & _
-
"from the database." _
-
& Err.Number & ", " & Err.Description
-
-
End Sub
-
-
Public Sub cmdMovePrevious_Click()
-
-
On Error GoTo DbError
-
-
'Move to the previous record in the result set, if the
-
'current record is not the first record.
-
If gRS.AbsolutePosition > 1 Then
-
-
gRS.MovePrevious
-
-
Forms!frmMasterDisplayA!txtCLAMNO = gRS.Fields(0)
-
Forms!frmMasterDisplayA!txtQuestion1 = gRS.Fields(1)
-
Forms!frmMasterDisplayA!txtVENDNM = gRS.Fields(2)
-
-
-
'MasterDisplay is a seperate module that will dispaly all of
-
'the fields in a single instance instead of under each move control
-
-
'MasterDisplay
-
-
End If
-
Exit Sub
-
-
DbError:
-
-
MsgBox "There was an error retrieving information " & _
-
"from the database." _
-
& Err.Number & ", " & Err.Description
-
-
End Sub
0 1355 Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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...
|
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,
|
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
| |
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
|
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
|
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.
|
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;
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |