Microsoft Office updates that are not backward compatable withMicrosoft VB 6.5

K

kim.forbes

Hi,

I am a VB and VBA novice who inherited an Access Database with VB code
that suddenly doesn't work on any machine or for any backup. I've
looked at the code and to my novice eyes it seems OK. I was wondering
if there was any VB or VBA change that would make this code suddenly
break. The first error I get is:
"Duplicate Declaration for current scope"


There are the duplications:
Private Sub txtSearchVal_Change()
Dim rst, rstFill As ADODB.Recordset
Dim sqlQuery, fillQuery As String
Dim ChurchID, envYear As Integer
Dim ChurchID As Integer
Dim identifier As Variant
Dim msgOK, intPosition As Integer
Dim LastName, firstName As String
Dim idType As Integer

I see that ChurchID is a duplicate declaration; but everything worked
fine until about a month and 1/2 ago, any ideas why it suddenly isn't
working?

Thanks
 
K

Karl E. Peterson

Hi,

I am a VB and VBA novice who inherited an Access Database with VB code
that suddenly doesn't work on any machine or for any backup. I've
looked at the code and to my novice eyes it seems OK. I was wondering
if there was any VB or VBA change that would make this code suddenly
break. The first error I get is:
"Duplicate Declaration for current scope"

That's not okay.
There are the duplications:
Private Sub txtSearchVal_Change()
Dim rst, rstFill As ADODB.Recordset
Dim sqlQuery, fillQuery As String
Dim ChurchID, envYear As Integer
Dim ChurchID As Integer
Dim identifier As Variant
Dim msgOK, intPosition As Integer
Dim LastName, firstName As String
Dim idType As Integer

I see that ChurchID is a duplicate declaration; but everything worked
fine until about a month and 1/2 ago, any ideas why it suddenly isn't
working?

Someone editted it. You can't declare two variables with the same name. Odds are,
the explicit one (As Integer) is the correct one. You should be able to easily test
this with a few iterative comments:

'Dim ChurchID, envYear As Integer
Dim envYear As Integer
Dim ChurchID As Integer

Run. If that doesn't work, then:

Dim ChurchID, envYear As Integer
'Dim ChurchID As Integer

Run. Note any further errors, and proceed similarly. (And *hope* the person who
editted it didn't do anything worse than this!)
 
N

Norman Yuan

Also, in VB/A

Dim rst, rstFill As ADODB.Recordset

is different from

Dim rst As ADODB.Recordset
Dim rstFill As ADODB.Recordset

For the former,

rst is declared as Variant, since no type is specified with "As" keyword.
That is, in VB, any variable declared without "As" will be Variant, whether
it is declared in the same line of code, seperated with "," or not. For
better readability and for the explicity, I never declare variable in one
line of code in VB.
 
K

kim.forbes

Also, in VB/A

Dim rst, rstFill As ADODB.Recordset

is different from

Dim rst As ADODB.Recordset
Dim rstFill As ADODB.Recordset

For the former,

rst is declared as Variant, since no type is specified with "As" keyword.
That is, in VB, any variable declared without "As" will be Variant, whether
it is declared in the same line of code, seperated with "," or not. For
better readability and for the explicity, I never declare variable in one
line of code in VB.










- Show quoted text -

Thanks for the replys.
I made the changes and got an "invalid method" error. I replaced the
me.field references with me!references and everything works find now.

Thanks again!
Kim
 

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