Fog Creek Software
g
Discussion Board




whats wrong wiv this?

i have written vba code in microsoft access 97, tried to run it in access xp and i cannot what is wrong wiv it.. the code i have is below!
Dim db As Database
Dim rstpurchase As Recordset
Dim rstproducts As Recordset
Dim strmark As String
Dim strname As String
'opens database and record sets
Set db = CurrentDb
Set rstpurchase = db.OpenRecordset("purchase")
Set rstproducts = db.OpenRecordset("products")
'passes product to string for search
strname = "product id = Me!productid"
'finds the name in the record
rstproducts.FindFirst strname
'strmark = rstproducts.Bookmark
rstproducts.Edit
rstproducts!numberinstock = rstproducts!numberinstock - 1
rstproducts.Update
rstproducts.Close
rstpurchase.Close


thanx

sarah

Sarah
Wednesday, February 4, 2004

sarah, please do not give this much info for us, otherwise there would be a chance that we would be able to answer your question



  
Wednesday, February 4, 2004

It's that stinking hungarian notation that biting your backside.

Czech
Wednesday, February 4, 2004

sarcasm is the lowest form of wit!! did you know that? forget it, i have a brain i'll do it myself! 

sarah
Wednesday, February 4, 2004

sarah,

sarcasm or not, the guys have a point. You need to provide more information if you expect useful answers...

1) What kind of error are you seeing? Error messages?

2) What steps did you already take to find a workaround?

Patrik
Wednesday, February 4, 2004

These two lines...

strname = "product id = Me!productid"
rstproducts.FindFirst strname

...bother me, because (A) you shouldn't use spaces in table names or field names, but (B) if you do, you should enclose them in brackets.

I'm also concerned that you don't prefix your Database and Recordset declarations with DAO.  ADO and DAO both have a Recordset class, so the prefix is the most straightforward way to make sure you're getting the one you want.

And have you enabled the reference to DAO?

Kyralessa
Wednesday, February 4, 2004

DAO vs ADO

In XP ADO is the default.
In 97 DAO is the default.

This looks like DAO code.
Move the reference to DAO up above ADO.

Bill K Ramsey
Wednesday, February 4, 2004

Bill beat me to it, but there's still something I can add:  if you explicitly declare all your recordsets "As DAO.Recordset", your code will work even if the references get reordered somehow.

Sam Livingston-Gray
Wednesday, February 4, 2004

...oh, and which line gives you the error and what does that error say?  (From the other comments, I'm guessing most of them, but it's only productive to fix them one at a time...)

Sam Livingston-Gray
Wednesday, February 4, 2004

"if you explicitly declare all your recordsets 'As DAO.Recordset', your code will work even if the references get reordered somehow."

But not if DAO isn't enabled in the first place--and in Access 2000 and later, by default it isn't.  In the Code Window, you have to go to Tools > References to find the DAO line and checkmark it.

(Boy is this thread some good shooting-in-the-dark.  Maybe we should start more basic:  "Is your computer plugged in?")

Kyralessa
Wednesday, February 4, 2004

strname = "product id = Me!productid"

should probably be

strname = "[product id] = " & Me!productid

unless productid is a string:

strname = "[product id] = '" & Me!productid & "'"

Gary
Wednesday, February 4, 2004

I'm gonna call the OP's bluff.  Why be a mangina?

There are no 19 year old girls that I know of that sit around and code VBA even for their father.  On top of that, they certainly don't seek out some obscure message board on the internet to ask these types of questions.

This all sounds a tad suspicious.

I'm guessing this person is a regular poster to this board.


Wednesday, February 4, 2004

"There are no 19 year old girls that I know of that sit around and code VBA even for their father.  On top of that, they certainly don't seek out some obscure message board on the internet to ask these types of questions."

Out of 6 billion people in the world, there couldn't be even one?

Kyralessa
Wednesday, February 4, 2004

sarah wrote:
"sarcasm is the lowest form of wit!! did you know that? forget it, i have a brain i'll do it myself"

one question for sarah:
- then why did you opened this thread?

  
Wednesday, February 4, 2004

I'd be willing to bet it's Philo.

Philo signs his posts exactly like 'Sarah' did.

Also this person speaks a bit more elegantly than any 19 year old girl I've known.

That comment about sarcasm is on the edge for a 19 year old.


Wednesday, February 4, 2004

Oh and porting VBA code from Access 97 to Access XP?  That's the last thing any 19 year old girls I know would be doing.  The first post about the database was half-way believable but now it's gone over the edge.


Wednesday, February 4, 2004

How do ya know she's 19?

Anonymous Developer
Wednesday, February 4, 2004

http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=108257&ixReplies=32

Third to last post.


Wednesday, February 4, 2004

Thanks blank.

Maybe she's 19, maybe she's not. But why not just give her the benefit of the doubt and help her out anyway? Why give her a hard time? Geez, and you wonder why most geeks don't have a significant other? :-P

Anonymous Developer
Wednesday, February 4, 2004

If sarcasm is the lowest form of wit, where does "mangina" fall?


Wednesday, February 4, 2004

> wiv

Sarah, I know a good speech therapist that may be able to help you with your disability. There's no need to suffer any longer.

Dennis Atkins
Wednesday, February 4, 2004

For a kinder, gentler messageboard, visit http://www.tek-tips.com/ where your question is answered with less ... fuss.  They have quite busy Access forums, since it seems to be the program everyone begins using without ever consulting a manual.

Not that I'm accusing you of that.  The point is that they answer questions like yours all the time.

pds
Wednesday, February 4, 2004

For all things Access, try the newsgroup comp.databases.ms-access.

Martha
Wednesday, February 4, 2004

Oh, and I generally have good luck with Google Groups as long as I include "access [version]" with my search string.

Sam Livingston-Gray
Wednesday, February 4, 2004

She'll get reamed there worse than here if she posts such a vague question, though.

Kyralessa
Wednesday, February 4, 2004

Experts-Exchange also has excellent help.  Last time we had occasion to post a question, our problem was solved in less than ten minutes.

The people there were very motivated to answer and were having a friendly competition over who could get the "best" answer to us first.

Phibian
Wednesday, February 4, 2004

Are you guys blind?

You are feeding a troll.


Wednesday, February 4, 2004

"Out of 6 billion people in the world, there couldn't be even one?"



I'm a girl-person; and when I was 19,  I was halfway through my comp sci degree...

(Granted,  I was doing "proper" programming rather than VBA;  but still..)

Bleh
Wednesday, February 4, 2004

I'll bet you had a better command of written English than fashion-major Sarah, though.

Kyralessa
Wednesday, February 4, 2004

Probably (:

Bleh
Wednesday, February 4, 2004

no comment in the last 24 hrs, thread closed.

  
Thursday, February 5, 2004

i didnt come on this site so you can discuss my age/english/who i am... i came on for help.... which i didnt find! ta chucks!
sarah

sarah
Friday, February 6, 2004

*  Recent Topics

*  Fog Creek Home