Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I manipulate records in code?

Status
Not open for further replies.

nyx

Programmer
Jul 25, 2004
20
0
0
AU
Hi,

I'm trying to figure out how I can "open" the database within an Access procedure to manipulate the records through code.

I tried doing the following:

dim db as database
dim rs as recordset

set db = opendatabase("mydata.mdb")
set rs = db.openrecordset("myrec",dbopendynaset)

Now, the 'set db' line is giving me an access error which is obvious because I have the database already open. My question then is how do I make reference to it so that I can create a recordset object to manage?

Any help would be greatly appreciated!

thanks
 
hi,

thanks for the help!

well, it worked... sorta. :)

It got me past my first problem, but now it will not perform the 'set rs' line; says 'Type Mismatch'

AH! this is driving me crazy. I never had so much trouble accessing an Access db in VB. :(

any help?

thanks
 
You're not alone in being frustrated while figuring out Access VB.
I don't know if the set rs=... is the offending line. I presume that "myrec" is the name of a table you are referencing in that line?
 
It sure is frustrating....

you would be correct in assuming that 'myrec' is the name of the table I wish to reference.

ideas?
 
I wonder if there is some other line of code that you have inserted that may be causing the error. For instance, putting a string into a number datatype will cause this kind of error.

Does your code window come up when the error occurs and displays a particular line?
 
hey,

k, I fixed it! :)

had to declare the recordset variable as a DAO.Recordset type instead of just a Recordset type... I have no idea what difference that is. :\ guess its just one of those "Access" tidbits...

Thanks for your help though. I appreciate it.

... now I gotta figure out this shell() problem... heheh I tell ya... Access sure is funny

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top