2003 Code Not Working in 2007

C

CJ

Hi Groupies:

I borrowed this code from a 2003 database and am trying to get it to work in
2007. I don't do code very well so I need some help.

Private Sub cmdDuplicate_Click()
Dim wsNewWO As Workspace, dbNewWO As Database, rsDupeWO As Recordset
Set wsNewWO = DBEngine.Workspaces(0)
Set dbNewWO = CurrentDb()

DoCmd.OpenQuery "qappTempDuplicate"

Set rsDupeWO = dbNewWO.OpenRecordset("tblTempDuplicate",
dbOpenDynaset)

rsDupeWO.Edit

WOSeq = fcnGetNextSequence
rsDupeWO.Close

End Sub

I get a break on "rsDupeWO.Edit" with the message Method or Data Member Not
Found.

I need to run the qappTempDuplicate query to hold a record of data.
Then I need a new WOSeq generated and have that number replace the existing
WOSeq in the record in the query.

I hope this makes sense.....
 
M

Michael J. Strickland

CJ said:
Hi Groupies:

I borrowed this code from a 2003 database and am trying to get it to
work in 2007. I don't do code very well so I need some help.

Private Sub cmdDuplicate_Click()
Dim wsNewWO As Workspace, dbNewWO As Database, rsDupeWO As
Recordset
Set wsNewWO = DBEngine.Workspaces(0)
Set dbNewWO = CurrentDb()

DoCmd.OpenQuery "qappTempDuplicate"

Set rsDupeWO = dbNewWO.OpenRecordset("tblTempDuplicate",
dbOpenDynaset)

rsDupeWO.Edit

WOSeq = fcnGetNextSequence
rsDupeWO.Close

End Sub

I get a break on "rsDupeWO.Edit" with the message Method or Data
Member Not Found.

I need to run the qappTempDuplicate query to hold a record of data.
Then I need a new WOSeq generated and have that number replace the
existing WOSeq in the record in the query.

I hope this makes sense.....


Do you have the DAO reference set?

(Tools->References)



--
 
C

CJ

Hi Michael:

Ummm, no I don't have the DAO reference set. I'm having a heck of time
trying to
get it to turn on because it keeps saying that I have Name Conflicts.

I have gone through and made sure that all Command Buttons and Combo Boxes
have unique names. I'm not sure what else I need to check.

Any ideas?
 
M

Mike Painter

You will have to resolve those and have the reference set to make your code
run.
Usually a search from VB will find them.
Note also that

rsDupeWO.Edit

WOSeq = fcnGetNextSequence
rsDupeWO.Close

needs a rsDupeWO.update to save the change if WOSeq is really rsDupeWO!WOSeq

I suspect an update query would do this.
 
C

CJ

OK, will do. Is it only items that I have created like combos and command
buttons that need to be unique?
I shouldn't have to edit all of the Form_Load events and things should I?
 
P

Paul Shapiro

In the line where you declare the rsDupeWO variable, you need to
disambiguate the declaration. Unfortunately, both ADO and DAO have Recordset
objects. Only the DAO recordset object has the .Edit method. So the kind of
recordset you are creating depends on whether ADO or DAO is listed higher in
the VBA References dialog.

The cleanest approach is to declare exactly what you want, with either one
of these 2 statements:
Dim rsDupeWO As DAO.Recordset
or
Dim rsDupeWO As ADODB.Recordset

Ideally you should do the same for all DAO/ADODB declarations. It helps
reduce the code's sensitivity to external conditions, namely which library
is listed earlier in the VBA References.
 

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