Having problems when converting to Access 2003

G

Guest

I am having problems running this code on Access 2002 software. The code was
made in 2002 then recently I converted to 2003 and sent out a new FE. Now
people running 2002 get an error when running this report. The users who are
on 2003 can run OK.

I get a complie error "Can't find project or library". What can done???

Thanks

On Error GoTo Err_Handler
'Purpose: Open the report filtered to the items selected in the list box.
'Author: Allen J Browne, 2004. http://allenbrowne.com
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.

strDelim = """" 'Delimiter appropriate to field type. See
note 1.
strDoc = "Program-Project Detail by Qtr"

'Loop through the ItemsSelected in the list box.
With Me.Program
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """, "
End If
Next
End With

'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[Program] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If

'Report will not filter if open, so close it. For Access 97, see note 3.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If

'Omit the last argument for Access 2000 and earlier. See note 4.
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip



Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then 'Ignore "Report cancelled" error.
'MsgBox "Error " & Err.Number & " - " & Err.Description,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub
 
A

Allen Browne

Jim, if the code works in A2002 but fails in A2003, there is a problem with
references, or with the name of the module.

To solve refrence issues, see:
http://allenbrowne.com/ser-38.html

Make sure the module where this code is stored is not the same as:
a) the name of the procedure;
b) the name of your project.
 
G

Guest

Should I load the "c:\program files\microsoft office\office10\msacc.olb" ?
Does A2202 use this file?
I lloked on my laptop and don't have this file loaded in the reference
table. Where do I get it?

Allen Browne said:
Jim, if the code works in A2002 but fails in A2003, there is a problem with
references, or with the name of the module.

To solve refrence issues, see:
http://allenbrowne.com/ser-38.html

Make sure the module where this code is stored is not the same as:
a) the name of the procedure;
b) the name of your project.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

jim said:
I am having problems running this code on Access 2002 software. The code
was
made in 2002 then recently I converted to 2003 and sent out a new FE. Now
people running 2002 get an error when running this report. The users who
are
on 2003 can run OK.

I get a complie error "Can't find project or library". What can done???

Thanks

On Error GoTo Err_Handler
'Purpose: Open the report filtered to the items selected in the list
box.
'Author: Allen J Browne, 2004. http://allenbrowne.com
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.

strDelim = """" 'Delimiter appropriate to field type. See
note 1.
strDoc = "Program-Project Detail by Qtr"

'Loop through the ItemsSelected in the list box.
With Me.Program
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) & """,
"
End If
Next
End With

'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[Program] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If

'Report will not filter if open, so close it. For Access 97, see note
3.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If

'Omit the last argument for Access 2000 and earlier. See note 4.
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip



Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then 'Ignore "Report cancelled" error.
'MsgBox "Error " & Err.Number & " - " & Err.Description,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub
 
A

Allen Browne

If you use Access 2002, that is an essential file if your database uses any
code or functions.

If you use Access 2002, you need to msacc.olb in from Office11 folder
instead.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

jim said:
Should I load the "c:\program files\microsoft office\office10\msacc.olb"
?
Does A2202 use this file?
I lloked on my laptop and don't have this file loaded in the reference
table. Where do I get it?

Allen Browne said:
Jim, if the code works in A2002 but fails in A2003, there is a problem
with
references, or with the name of the module.

To solve refrence issues, see:
http://allenbrowne.com/ser-38.html

Make sure the module where this code is stored is not the same as:
a) the name of the procedure;
b) the name of your project.


jim said:
I am having problems running this code on Access 2002 software. The
code
was
made in 2002 then recently I converted to 2003 and sent out a new FE.
Now
people running 2002 get an error when running this report. The users
who
are
on 2003 can run OK.

I get a complie error "Can't find project or library". What can
done???

Thanks

On Error GoTo Err_Handler
'Purpose: Open the report filtered to the items selected in the
list
box.
'Author: Allen J Browne, 2004. http://allenbrowne.com
Dim varItem As Variant 'Selected items
Dim strWhere As String 'String to use as WhereCondition
Dim strDescrip As String 'Description of WhereCondition
Dim lngLen As Long 'Length of string
Dim strDelim As String 'Delimiter for this field type.
Dim strDoc As String 'Name of report to open.

strDelim = """" 'Delimiter appropriate to field type. See
note 1.
strDoc = "Program-Project Detail by Qtr"

'Loop through the ItemsSelected in the list box.
With Me.Program
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column (hidden).
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
'Build up the description from the text in the visible
column. See note 2.
strDescrip = strDescrip & """" & .Column(1, varItem) &
""",
"
End If
Next
End With

'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[Program] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "Categories: " & Left$(strDescrip, lngLen)
End If
End If

'Report will not filter if open, so close it. For Access 97, see
note
3.
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If

'Omit the last argument for Access 2000 and earlier. See note 4.
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip



Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then 'Ignore "Report cancelled" error.
'MsgBox "Error " & Err.Number & " - " & Err.Description,
"cmdPreview_Click"
End If
Resume Exit_Handler
End Sub
 
G

Guest

Hi Jim,
Should I load the "c:\program files\microsoft office\office10\msacc.olb"?

No. This file is the "Microsoft Access Object Library". This library, and
the first one in the list, "Visual Basic for Applications", are required of
all Access applications. Access 2002 uses version 10.0, while Access 2003
uses version 11.0. These first two references should be pretty much self
correcting. Are you saying that you are seeing the word "MISSING" next to
this checked reference?

Have you tried refreshing the references collection? You can do this my
adding a new reference, clicking on the OK button to dismiss the reference
dialog. Then go back in and remove it, since you don't want any unnecessary
references included.

In the VBA editor, click on Debug > Compile ProjectName. What happens? Does
your code compile properly, or do you receive a compile-time error?


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Should I load the "c:\program files\microsoft office\office10\msacc.olb" ?
Does A2202 use this file?
I lloked on my laptop and don't have this file loaded in the reference
table. Where do I get it?
 
R

Rebeccca Turner

well i would talk to the libarian about that one thanks for useing lilly and
lola good advise line write back!!!
 

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