Returning to previous record on Scrolling form

B

Brian

I have a very long form with sometimes hundreds of records. For each record,
there is a text box where the user can enter a quantity to be added/deleted
to the existing quantity. Once the quantity has been added/deleted, the form
requeries so that the quantity displayed is now accurate.

Since the form is so long, I want a way for the form to return to the record
that the user just updated. In Access 2003, I used this code:

dim rst as recordset
dim IntKeyVal as string
IntKeyVal = idx_IDNumber
Application.Echo False

<<<other VBA code here to add/delete from existing quantity>>>

set rst = me.recordsetclone
rst.findfirst IntKeyVal
me.bookmark = rst.bookmark
Application.Echo True

This worked well in Access 2003, but does not work in Access 2007. Access
2007 returns an error that says "Run Time Error '3001' Invalid Argument" and
when I debug, highlights the rst.findfirst IntKeyVal line. I should point
out that the IntKeyVal value is correct (when I hover over the line to see
the value).

Any help anyone can give would be most appreciated.

Brian
 
C

Carl Rapson

Brian said:
I have a very long form with sometimes hundreds of records. For each
record,
there is a text box where the user can enter a quantity to be
added/deleted
to the existing quantity. Once the quantity has been added/deleted, the
form
requeries so that the quantity displayed is now accurate.

Since the form is so long, I want a way for the form to return to the
record
that the user just updated. In Access 2003, I used this code:

dim rst as recordset
dim IntKeyVal as string
IntKeyVal = idx_IDNumber
Application.Echo False

<<<other VBA code here to add/delete from existing quantity>>>

set rst = me.recordsetclone
rst.findfirst IntKeyVal
me.bookmark = rst.bookmark
Application.Echo True

This worked well in Access 2003, but does not work in Access 2007. Access
2007 returns an error that says "Run Time Error '3001' Invalid Argument"
and
when I debug, highlights the rst.findfirst IntKeyVal line. I should point
out that the IntKeyVal value is correct (when I hover over the line to see
the value).

Any help anyone can give would be most appreciated.

Brian

If you're using DAO, try explicitly typing the rst variable:

dim rst as DAO.recordset


Carl Rapson
 
B

Brian

I've tried both:

dim rst as recordset
dim rst as dao.recordset

I use DAO so I tried that first. When that didn't work., I eliminated the
DAO and it still didn't work.

The error is the same for both.
ANy other suggestions?

Brian
 
G

George Nicholson

rst.findfirst IntKeyVal
this line is incomplete

rst.FindFirst CriteriaPhraseAsString

"CriteriaPhrase" is like a SQL Where clause without the Where:
rst.FindFirst "SomeFieldname = SomeValue"
rst.FindFirst "[IDNumber] = '" & IntkeyValue & "'" (if IDNumber is a
text field)
rst.FindFirst "[IDNumber] = " & intKeyValue (if IDNumber is a numeric
field)
This worked well in Access 2003,
No, that's not possible. Your code *must* have changed.

HTH,
 
G

George Nicholson

rst.findfirst IntKeyVal
this line is incomplete

rst.FindFirst CriteriaPhraseAsString

"CriteriaPhrase" is like a SQL Where clause without the Where:
rst.FindFirst "SomeFieldname = SomeValue"
rst.FindFirst "[IDNumber] = '" & IntkeyValue & "'" (if IDNumber is a
text field)
rst.FindFirst "[IDNumber] = " & intKeyValue (if IDNumber is a numeric
field)
This worked well in Access 2003,
No, that's not possible. Your code *must* have changed.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top