473,505 Members | 15,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access and SQL Backend - moving to next record - HHHELLLPPP!

I am using Access 2000 as the front end and MS SQL 2000 as the backend.

I have a one record form that I set using something like:

strSQL = "SELECT * FROM dbo_WBACCT WHERE
(((dbo_WBACCT.ACCOUNT)='"423456"'));"
Me.RecordSource = strSQL

Obviously I only want one record at a time because the database is very
big.

Some of the data looks like this:

ACCOUNT Name
2344566 Smith
2344578 Jones
2344582 Davis

The data is sorted on account number. If I am looking at account #
2344578, I want to click a button to view the next account number which
in the example is 2344582.

The code for the button must find that the next account # is 2344582 so
it can change the recordsource for the form again.

How can I efficiently find this next account number. Using ADO's
rst.Find is too slow to trudge through the whole recordset to find
account # 2344578 and then doing a movenext. It takes a could of
minutes.

Seems simple, but I am only spinning my wheels. You might ask why one
would want to look at the next account number. The answer is because
this is for a utility that wants to see the next person on the street.
The next account # is the neighbor of the previous account #. What do
the experts say?

Aug 4 '06 #1
11 3514
scsTiger wrote:
I am using Access 2000 as the front end and MS SQL 2000 as the
backend.

I have a one record form that I set using something like:

strSQL = "SELECT * FROM dbo_WBACCT WHERE
(((dbo_WBACCT.ACCOUNT)='"423456"'));"
Me.RecordSource = strSQL

Obviously I only want one record at a time because the database is
very big.

Some of the data looks like this:

ACCOUNT Name
2344566 Smith
2344578 Jones
2344582 Davis

The data is sorted on account number. If I am looking at account #
2344578, I want to click a button to view the next account number
which in the example is 2344582.

The code for the button must find that the next account # is 2344582
so it can change the recordsource for the form again.

How can I efficiently find this next account number. Using ADO's
rst.Find is too slow to trudge through the whole recordset to find
account # 2344578 and then doing a movenext. It takes a could of
minutes.

Seems simple, but I am only spinning my wheels. You might ask why one
would want to look at the next account number. The answer is because
this is for a utility that wants to see the next person on the street.
The next account # is the neighbor of the previous account #. What
do the experts say?
Populate a ListBox or ComboBox with a RowSource of...

SELECT DISTINCT ACCOUNT FROM dbo_WBACCT

....Then use that list to choose the account data to retrieve.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 4 '06 #2
You have not clearly specified if your table is the recordsource of a
form (which is sounds like it could be) or if your form is a search form
where you enter an account number and search for a record.

If all you want is the next record in the table, the easiest thing is to
create a view in the sql server backend which would contain the dataset
you need in the desired sort order. Then you can link to that view with
ODBC. Then just use navigation buttons on the form to navigate the
recordset.

An equivalent method in Access would be to retrieve a list of your
desired accounts and store that list in a table. Use that table as the
recordsource for a form. Then create a subform that uses the main table
as its recordsource and link the form to the subform using the Account
field. When you iterate through the mainform the corresponding record
will show up in the subform - Like a Master/Detail setup.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 4 '06 #3

Rick Brandt wrote:
scsTiger wrote:
I am using Access 2000 as the front end and MS SQL 2000 as the
backend.

I have a one record form that I set using something like:

strSQL = "SELECT * FROM dbo_WBACCT WHERE
(((dbo_WBACCT.ACCOUNT)='"423456"'));"
Me.RecordSource = strSQL

Obviously I only want one record at a time because the database is
very big.

Some of the data looks like this:

ACCOUNT Name
2344566 Smith
2344578 Jones
2344582 Davis

The data is sorted on account number. If I am looking at account #
2344578, I want to click a button to view the next account number
which in the example is 2344582.

The code for the button must find that the next account # is 2344582
so it can change the recordsource for the form again.

How can I efficiently find this next account number. Using ADO's
rst.Find is too slow to trudge through the whole recordset to find
account # 2344578 and then doing a movenext. It takes a could of
minutes.

Seems simple, but I am only spinning my wheels. You might ask why one
would want to look at the next account number. The answer is because
this is for a utility that wants to see the next person on the street.
The next account # is the neighbor of the previous account #. What
do the experts say?

Populate a ListBox or ComboBox with a RowSource of...

SELECT DISTINCT ACCOUNT FROM dbo_WBACCT

...Then use that list to choose the account data to retrieve.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Rick,

Thanks for your help. db_WBACCT is huge. Will this be quicker than
just programmatically opening a recordset and using the FIND method.
Also, with the data in the list box, what way are you suggestting
programmatically to retrieve that next account number? Having the user
choose the next account # instead of hitting some kind of next button?
Sorry for my confusion.

Aug 4 '06 #4
Thanks Rich. Yes I am talking about a recordsource of a form. I am
grabbing only one record from the SQL backend due to the large amount
of records. I use a separate popup search form to find the account
they initially want to look at. It then sets the recordsource of the
main form. That part works fine. The problem comes in when they want
to step to the next account. I will first try the view in the sql
backend method you describe. I may need more detail on that one as I
am (obviously) new to SQL server.


Rich P wrote:
You have not clearly specified if your table is the recordsource of a
form (which is sounds like it could be) or if your form is a search form
where you enter an account number and search for a record.

If all you want is the next record in the table, the easiest thing is to
create a view in the sql server backend which would contain the dataset
you need in the desired sort order. Then you can link to that view with
ODBC. Then just use navigation buttons on the form to navigate the
recordset.

An equivalent method in Access would be to retrieve a list of your
desired accounts and store that list in a table. Use that table as the
recordsource for a form. Then create a subform that uses the main table
as its recordsource and link the form to the subform using the Account
field. When you iterate through the mainform the corresponding record
will show up in the subform - Like a Master/Detail setup.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 4 '06 #5
For help with Sql Server issues you can go to the Sql Tab in
DeveloperDex (www.devdex.com) or go to the MSDN Newsgroup
(http://msdn.microsoft.com/newsgroups/)

At the MSDN NG go to Enterprise Development then on the dropdown go to
Sql Server. On the next dropdown go to sqlserver.programming.

When you post a question at the MSDN NG you will be asked to register.
Just put in any old email and password. That will be your ID and
password (its free - all microsoft).

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 4 '06 #6
Interesting problem...

You could try for the next buttion:
strSQL = "SELECT top 1 from FROM dbo_WBACCT WHERE " & _
ACCOUNT " & """" & me!Account & """" & _
"order by Account"

Me.RecordSource = strSQL

You would change the above to the reverse for the prevous arrow.....

strSQL = "SELECT top 1 from FROM dbo_WBACCT WHERE " & _
ACCOUNT < " & """" & me!Account & """" & _
"order by Account dsnd"

The above would fetch ONLY one record .and the record would be the next
account in the file....

It should work, and if there is 1, or million records in the file..the
performance should be instant....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 4 '06 #7
Albert,

Thanks. I'm getting a run time error. Seems its choking on the "TOP
1" portion of the sql statement. If I change top 1 to * , I get no
error. Any suggestions?

Thanks,
Jeff

For some reason, Access doesn't like the top 1 part of it.

Albert D. Kallal wrote:
Interesting problem...

You could try for the next buttion:
strSQL = "SELECT top 1 from FROM dbo_WBACCT WHERE " & _
ACCOUNT " & """" & me!Account & """" & _
"order by Account"

Me.RecordSource = strSQL

You would change the above to the reverse for the prevous arrow.....

strSQL = "SELECT top 1 from FROM dbo_WBACCT WHERE " & _
ACCOUNT < " & """" & me!Account & """" & _
"order by Account dsnd"

The above would fetch ONLY one record .and the record would be the next
account in the file....

It should work, and if there is 1, or million records in the file..the
performance should be instant....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 4 '06 #8
Well, we need some fields!!!

Try

strSQL = "SELECT top 1 * from FROM dbo_WBACCT WHERE " & _
ACCOUNT " & """" & me!Account & """" & _
"order by Account"

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 4 '06 #9
Albert,

This worked perfectly. Sorry I did not catch the missing *. Thanks to
you and everyone else that was so quick to help.

Jeff

Albert D. Kallal wrote:
Well, we need some fields!!!

Try

strSQL = "SELECT top 1 * from FROM dbo_WBACCT WHERE " & _
ACCOUNT " & """" & me!Account & """" & _
"order by Account"

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Aug 4 '06 #10
scsTiger wrote:
Rick,

Thanks for your help. db_WBACCT is huge. Will this be quicker than
just programmatically opening a recordset and using the FIND method.
Also, with the data in the list box, what way are you suggestting
programmatically to retrieve that next account number? Having the
user choose the next account # instead of hitting some kind of next
button? Sorry for my confusion.
Huge, perhaps but how long is the list of distinct accounts? Still huge?
Because that query will be run on the server whereas your find is probably being
processed locally.

Generally speaking a rowset consisting of a single field would have to be
awfully tall to be "large" in terms of data retrieval.

I suppose you could fetch 10 or so at a time by using the TOP predicate.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Aug 4 '06 #11
Rick,

Thanks for your reply, Albert gave me the following SQL statement to
return the next account:

strSQL = "SELECT top 1 * from FROM dbo_WBACCT WHERE " & _
ACCOUNT " & """" & me!Account & """" & _
"order by Account"

Rick Brandt wrote:
scsTiger wrote:
Rick,

Thanks for your help. db_WBACCT is huge. Will this be quicker than
just programmatically opening a recordset and using the FIND method.
Also, with the data in the list box, what way are you suggestting
programmatically to retrieve that next account number? Having the
user choose the next account # instead of hitting some kind of next
button? Sorry for my confusion.

Huge, perhaps but how long is the list of distinct accounts? Still huge?
Because that query will be run on the server whereas your find is probably being
processed locally.

Generally speaking a rowset consisting of a single field would have to be
awfully tall to be "large" in terms of data retrieval.

I suppose you could fetch 10 or so at a time by using the TOP predicate.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 4 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
4017
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
4
2191
by: James P. | last post by:
Hello there, I have a bound-form using Navigator so that the user can move back and forth to update record in the form. Every time a record was modified and the user clicks the Navigator to...
6
2781
by: MS | last post by:
Access 97 here. I want a simple way to "lock" certain records on a form. Some records remain "live" until all data is available which happens over time. When all the fields are complete, I want...
2
2237
by: Ian Baker | last post by:
We have developed an Access/Jet database (2000, XP & 2003 versions) that has been used by clients all around the world for several years and is extremely robust with 55 tables, 172 hard stored...
4
1284
by: jg1130 | last post by:
Greetings all, Here's my problem... I've built a small Access database that I placed on my server. I have one workstation connected to the database. The folder that the database is in on...
4
2379
by: corey11 | last post by:
I'm a very low-level developer with limited VB knowledge but nonetheless was able to put together a very user-friendly and extremely helpful Access 97 database for my company some 10 years back. We...
6
2663
by: jsacrey | last post by:
Hello everybody, I've got a bit of a situation that I could use some guidance with if possible. I work for an auditing firm where my users audit electronic shipping data for customers to see if...
6
6200
by: Mark | last post by:
Currently using MS Access 2000 and SQL Server Express. Using the current DAO OpenRecordset code listed below, however I keep getting the error message.... 3254: ODBC --Cannot lock all records ...
2
19403
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
7216
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,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7303
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,...
1
7018
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
7471
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
4699
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
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 ...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.