Report for current record

W

Woody

I have a database created with Access 97 that I have code
to run a report for only the current record. It works
fine. But when I copied the code to another database
created in Access 2000, it won't run. I get a run time
error "2465 Microsoft Access can't find the field 'I'
referred to in your expression".

Here's the code

Dim strWere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "rptPrintRecord", acViewPreview, strWhere
End If

Do I need to change something in the expression or is it
because code for 97 is different then 2000.
 
C

Cheryl Fischer

Woody,

I think you need to have two commas between acViewPreview and strWhere:

DoCmd.OpenReport "rptPrintRecord", acViewPreview, , strWhere

hth,
 
W

Woody

Tried that and it still don't work. Debugger showes it's
somewhere in strWhere = "[RunID] = " & Me.[RunID]
-----Original Message-----
Woody,

I think you need to have two commas between acViewPreview and strWhere:

DoCmd.OpenReport "rptPrintRecord", acViewPreview, , strWhere

hth,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Woody said:
I have a database created with Access 97 that I have code
to run a report for only the current record. It works
fine. But when I copied the code to another database
created in Access 2000, it won't run. I get a run time
error "2465 Microsoft Access can't find the field 'I'
referred to in your expression".

Here's the code

Dim strWere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "rptPrintRecord", acViewPreview, strWhere
End If

Do I need to change something in the expression or is it
because code for 97 is different then 2000.


.
 
V

Van T. Dinh

1. Not sure whether it is in your code or only on the post but you declare
strWere, not strWhere. Check Access VB Help on "Option Explicit" also.

2. On which line does the error happen? OpenReport statement? I can't see
how the error can happen on the strWhere assignment statement.

3. Open the Report by itself, i.e. not by code, and see if you get any
error.

--
HTH
Van T. Dinh
MVP (Access)




Woody said:
Tried that and it still don't work. Debugger showes it's
somewhere in strWhere = "[RunID] = " & Me.[RunID]
-----Original Message-----
Woody,

I think you need to have two commas between acViewPreview and strWhere:

DoCmd.OpenReport "rptPrintRecord", acViewPreview, , strWhere

hth,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Woody said:
I have a database created with Access 97 that I have code
to run a report for only the current record. It works
fine. But when I copied the code to another database
created in Access 2000, it won't run. I get a run time
error "2465 Microsoft Access can't find the field 'I'
referred to in your expression".

Here's the code

Dim strWere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "rptPrintRecord", acViewPreview, strWhere
End If

Do I need to change something in the expression or is it
because code for 97 is different then 2000.


.
 
W

Woody

I typed the statement in my message wrong, the code was
right. I can run the code without selecting a record and
I get the "select record statement" but when I select a
record and the code runs to the strWhere that's when I get
the error. I can open the report without the code and it
open's fine. Still puzzled!
-----Original Message-----
1. Not sure whether it is in your code or only on the post but you declare
strWere, not strWhere. Check Access VB Help on "Option Explicit" also.

2. On which line does the error happen? OpenReport statement? I can't see
how the error can happen on the strWhere assignment statement.

3. Open the Report by itself, i.e. not by code, and see if you get any
error.

--
HTH
Van T. Dinh
MVP (Access)




Woody said:
Tried that and it still don't work. Debugger showes it's
somewhere in strWhere = "[RunID] = " & Me.[RunID]
-----Original Message-----
Woody,

I think you need to have two commas between
acViewPreview
and strWhere:
DoCmd.OpenReport "rptPrintRecord",
acViewPreview, ,
strWhere
hth,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX

I have a database created with Access 97 that I have code
to run a report for only the current record. It works
fine. But when I copied the code to another database
created in Access 2000, it won't run. I get a run time
error "2465 Microsoft Access can't find the field 'I'
referred to in your expression".

Here's the code

Dim strWere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "rptPrintRecord", acViewPreview, strWhere
End If

Do I need to change something in the expression or is it
because code for 97 is different then 2000.



.


.
 
V

Van T. Dinh

1. Delete the strWhere assignment and the OpenReport statements and then
re-type them. It looks like there is a non-printable character (hence
invisible) somewhere in there.

2. Have you done a Compile to make sure there is no compilation error?

3. Have you checked the References Collection and make sure all A OK?
(See Douglas J. Steele's article:

http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html

4. If nothing works, try create a new (empty) database and import all
objects from the existing database.
 
C

Cheryl Fischer

While this *should not* make any difference at all, you might want to try
(just for grins) substituting the Bang operator instead of the Dot in your
expression. Substitute Me![ID] for Me.[ID]

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Woody said:
I typed the statement in my message wrong, the code was
right. I can run the code without selecting a record and
I get the "select record statement" but when I select a
record and the code runs to the strWhere that's when I get
the error. I can open the report without the code and it
open's fine. Still puzzled!
-----Original Message-----
1. Not sure whether it is in your code or only on the post but you declare
strWere, not strWhere. Check Access VB Help on "Option Explicit" also.

2. On which line does the error happen? OpenReport statement? I can't see
how the error can happen on the strWhere assignment statement.

3. Open the Report by itself, i.e. not by code, and see if you get any
error.

--
HTH
Van T. Dinh
MVP (Access)




Woody said:
Tried that and it still don't work. Debugger showes it's
somewhere in strWhere = "[RunID] = " & Me.[RunID]

-----Original Message-----
Woody,

I think you need to have two commas between acViewPreview
and strWhere:

DoCmd.OpenReport "rptPrintRecord", acViewPreview, ,
strWhere

hth,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX

I have a database created with Access 97 that I have
code
to run a report for only the current record. It works
fine. But when I copied the code to another database
created in Access 2000, it won't run. I get a run time
error "2465 Microsoft Access can't find the field 'I'
referred to in your expression".

Here's the code

Dim strWere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "rptPrintRecord", acViewPreview,
strWhere
End If

Do I need to change something in the expression or is it
because code for 97 is different then 2000.



.


.
 
W

woody

I appreciate everyone's help.

I did find some reference differences in the two
databases. The references that was selected in the 97, I
selected in the 2000 database. I still got the same error
message.

I tried the changing to the bang operator with no
success.

I created a new database and imported all the objects form
the original one and got the same response.

I even converted the 2000 to a 97 format but that didn't
help either.

I plan to start from scratch from my computer at home with
Access 97. I prefer that version anyway. That’s what I'm
use to working with.

Again thanks to all!
-----Original Message-----
I typed the statement in my message wrong, the code was
right. I can run the code without selecting a record and
I get the "select record statement" but when I select a
record and the code runs to the strWhere that's when I get
the error. I can open the report without the code and it
open's fine. Still puzzled!
-----Original Message-----
1. Not sure whether it is in your code or only on the post but you declare
strWere, not strWhere. Check Access VB Help on "Option Explicit" also.

2. On which line does the error happen? OpenReport statement? I can't see
how the error can happen on the strWhere assignment statement.

3. Open the Report by itself, i.e. not by code, and see if you get any
error.

--
HTH
Van T. Dinh
MVP (Access)




Woody said:
Tried that and it still don't work. Debugger showes it's
somewhere in strWhere = "[RunID] = " & Me.[RunID]

-----Original Message-----
Woody,

I think you need to have two commas between acViewPreview
and strWhere:

DoCmd.OpenReport "rptPrintRecord", acViewPreview, ,
strWhere

hth,
--
Cheryl Fischer
Law/Sys Associates
Houston, TX

I have a database created with Access 97 that I have
code
to run a report for only the current record. It works
fine. But when I copied the code to another database
created in Access 2000, it won't run. I get a run time
error "2465 Microsoft Access can't find the field 'I'
referred to in your expression".

Here's the code

Dim strWere As String
If Me.Dirty Then 'Save any changes.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "SELECT A RECORD TO PRINT"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "rptPrintRecord", acViewPreview,
strWhere
End If

Do I need to change something in the expression or is it
because code for 97 is different then 2000.



.


.
.
 

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