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

Navigation buttons

Hi, i want to do navigation button like first, previous, next and last using command button. When user click the first button, the first record in access must appear . I do using the coding below but it not going to first record , it goes to records in 288 row.

Private Sub cmdFirst_Click()

' Open a connection.
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & App.Path & "\Everspark2.mdb"
conn.CursorLocation = adUseClient
'Open the Connection
conn.Open


'Define an SQL statement (asking for all columns of the Solicitor table)
sqlString = " SELECT * FROM Alternator"

'execute the SQL statement and put the resulting set of record in recordset variable
Set rs1 = conn.Execute(sqlString)

rs1.MoveFirst
GetFields

rs1.Close
conn.Close

End Sub

Private Sub GetFields()
' Places field data into the text boxes -

txtAltId1.Text = rs1.Fields(0).Value
txtEversparkNo1.Text = rs1.Fields(1).Value
End Sub

Plz help me.Thanks in advance.
Apr 15 '08 #1
8 1286
debasisdas
8,127 Expert 4TB
What is the problem with your code ?

1.use the move methods
2.check for BOF/EOF
3.display the field in desired control.
Apr 15 '08 #2
try using Order by in Select statemenyt
Apr 15 '08 #3
Thanks for the reply . I had put the orderby clause in the coding , its work fine to first and last button but it not moved to next or previous data when click the associate button.
Apr 16 '08 #4
debasisdas
8,127 Expert 4TB
try to use this sample code
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFirst_Click()
  2.   On Error GoTo GoFirstError
  3.  
  4.   adoPrimaryRS.MoveFirst
  5.    Exit Sub
  6.  
  7. GoFirstError:
  8.   MsgBox Err.Description
  9. End Sub
  10.  
  11. Private Sub cmdLast_Click()
  12.   On Error GoTo GoLastError
  13.  
  14.   adoPrimaryRS.MoveLast
  15.    Exit Sub
  16.  
  17. GoLastError:
  18.   MsgBox Err.Description
  19. End Sub
  20.  
  21. Private Sub cmdNext_Click()
  22.   On Error GoTo GoNextError
  23.  
  24.   If Not adoPrimaryRS.EOF Then adoPrimaryRS.MoveNext
  25.   If adoPrimaryRS.EOF And adoPrimaryRS.RecordCount > 0 Then
  26.     Beep
  27.  
  28.     adoPrimaryRS.MoveLast
  29.   End If
  30.  
  31.   mbDataChanged = False
  32.  
  33.   Exit Sub
  34. GoNextError:
  35.   MsgBox Err.Description
  36. End Sub
  37.  
  38. Private Sub cmdPrevious_Click()
  39.   On Error GoTo GoPrevError
  40.  
  41.   If Not adoPrimaryRS.BOF Then adoPrimaryRS.MovePrevious
  42.   If adoPrimaryRS.BOF And adoPrimaryRS.RecordCount > 0 Then
  43.     Beep
  44.  
  45.     adoPrimaryRS.MoveFirst
  46.   End If
  47.  
  48.  Exit Sub
  49.  
  50. GoPrevError:
  51.   MsgBox Err.Description
  52. End Sub
  53.  
Apr 16 '08 #5
What is mbDataChanged = False at line 31 ?
I had try the coding the error message of
Operators is not allowed when the object is closed . What does the error mean ?
Apr 17 '08 #6
debasisdas
8,127 Expert 4TB
this code is part of an application. Just comment / remove that line.
Apr 17 '08 #7
On Error GoTo GoPrevError

If Not rs1.BOF Then rs1.MovePrevious
If rs1.BOF And rs1.RecordCount > 0 Then
Beep

rs1.MoveFirst
End If

Exit Sub

GoPrevError:
MsgBox Err.Description

I had used this code. But error occured. The error is
"Operation is not allowed when the object is closed "
What does the error mean ?
Apr 17 '08 #8
debasisdas
8,127 Expert 4TB
it seems you lack basic knowledge of Vb programming.

Have you opened the recordset or is the recordset open while you are tring to use the move methods.
Apr 17 '08 #9

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

Similar topics

5
by: Mike MacSween | last post by:
A single form (i.e. no subforms) opening full screen, how can I get the navigation buttons (Access built in) to be higher than the bottom of the screen. It annoys the users - they go for the nav...
6
by: MX1 | last post by:
Hi, I've created a series of navigation buttons to be used as a standard across many forms in an Access DB. Does anyone know an easy way to cut and paste these navigation buttons into each new...
2
by: PC Datasheet | last post by:
I have an AccessXP(A2000 mode) customer who says on one form the navigation buttons do nothing when he clicks on any of the 5 but the navigation buttons work on other forms. In my copy of the...
1
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be...
3
by: Jack Russell | last post by:
I want to add navigation buttons to a tabcontrol (somewhat like excel) How do I get the "tabs" to offset to the right so that I can draw the buttons on the left? TIA -- Remove norubbish to...
0
by: John Phelan-Cummings | last post by:
In the process of polishing up my (last) beta application; I have been exploring all the possible ways of speeding up my forms. I realized that numerous a forms under various application...
4
by: Jamey Shuemaker | last post by:
Howdy, Saw a couple threads from the past few years on this topic, but didn't really find any solutions. Here's one I found:...
9
by: mosscliffe | last post by:
I am struggling to find a python example of the scenario - I have. I have a python script, which generates a page with a search button (actually an input field). The data from the above...
3
by: Gary | last post by:
Afternoon Is it possible to display test alongside the Navigation Buttons in an MS Access form? I have a complex form containing a number of subforms where the Navigation Buttons are...
0
by: emalcolm_FLA | last post by:
Hello and TIA for your consideration. I have created several db's for a non-profit and they want custom navigation buttons to display "You are on the first record, last record, etc". With this...
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
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.