Reports

A

antonov

Hello again everybody.
I have created my tables and my forms. I've also created my reports but I
cannot get a report to open exactely at the record from which I call it...
How can I do that?
 
F

fredg

Hello again everybody.
I have created my tables and my forms. I've also created my reports but I
cannot get a report to open exactely at the record from which I call it...
How can I do that?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'
 
A

antonov

Fred, I have tried what you told me (I've changed [RecordID] into
[Dossier]). When I run the event it asks me to enter Parameter value....
what do I do wrong?
fredg said:
Hello again everybody.
I have created my tables and my forms. I've also created my reports but I
cannot get a report to open exactely at the record from which I call
it...
How can I do that?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'
 
F

fredg

Fred, I have tried what you told me (I've changed [RecordID] into
[Dossier]). When I run the event it asks me to enter Parameter value....
what do I do wrong?
fredg said:
Hello again everybody.
I have created my tables and my forms. I've also created my reports but I
cannot get a report to open exactely at the record from which I call
it...
How can I do that?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'

Is [Dossier] the actual name of your prime key field?
Is it spelled exactly like that?
Copy and paste your exact code.
 
A

antonov

Fred: this is the code as I have written it:

Private Sub ARRIVO_Click()
On Error GoTo Err_ARRIVO_Click

Dim stDocName As String

stDocName = "Arrivo"
DoCmd.OpenReport stDocName, acViewPreview, , "[Dossier]=""&[Dossier]&"""


Exit_ARRIVO_Click:
Exit Sub

Err_ARRIVO_Click:
MsgBox Err.Description
Resume Exit_ARRIVO_Click

End Sub

and this is the report's Record Source:
SELECT MAWB.Dossier, MAWB.MAWB, MAWB.AirLineCode, MAWB.Pieces, MAWB.Weight,
MAWB.CWeight, MAWB.Notified, MAWB.Notes, MAWB.DateOut, MAWB.DateIn,
MAWB.IdConsignee AS MAWB_IdConsignee, Consignee.Consignee, Consignee.Tel,
Consignee.Fax, Consignee_Contatti.IdContatto, Consignee_Contatti.IDConsignee
AS Consignee_Contatti_IDConsignee, Consignee_Contatti.Contatto,
Consignee_Contatti.Email



fredg said:
Fred, I have tried what you told me (I've changed [RecordID] into
[Dossier]). When I run the event it asks me to enter Parameter value....
what do I do wrong?
fredg said:
On Tue, 22 Nov 2005 21:13:46 +0100, antonov wrote:

Hello again everybody.
I have created my tables and my forms. I've also created my reports but
I
cannot get a report to open exactely at the record from which I call
it...
How can I do that?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'

Is [Dossier] the actual name of your prime key field?
Is it spelled exactly like that?
Copy and paste your exact code.
 
F

fredg

Fred: this is the code as I have written it:

Private Sub ARRIVO_Click()
On Error GoTo Err_ARRIVO_Click

Dim stDocName As String

stDocName = "Arrivo"
DoCmd.OpenReport stDocName, acViewPreview, , "[Dossier]=""&[Dossier]&"""

Exit_ARRIVO_Click:
Exit Sub

Err_ARRIVO_Click:
MsgBox Err.Description
Resume Exit_ARRIVO_Click

End Sub

and this is the report's Record Source:
SELECT MAWB.Dossier, MAWB.MAWB, MAWB.AirLineCode, MAWB.Pieces, MAWB.Weight,
MAWB.CWeight, MAWB.Notified, MAWB.Notes, MAWB.DateOut, MAWB.DateIn,
MAWB.IdConsignee AS MAWB_IdConsignee, Consignee.Consignee, Consignee.Tel,
Consignee.Fax, Consignee_Contatti.IdContatto, Consignee_Contatti.IDConsignee
AS Consignee_Contatti_IDConsignee, Consignee_Contatti.Contatto,
Consignee_Contatti.Email

fredg said:
Fred, I have tried what you told me (I've changed [RecordID] into
[Dossier]). When I run the event it asks me to enter Parameter value....
what do I do wrong?
On Tue, 22 Nov 2005 21:13:46 +0100, antonov wrote:

Hello again everybody.
I have created my tables and my forms. I've also created my reports but
I
cannot get a report to open exactely at the record from which I call
it...
How can I do that?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'

Is [Dossier] the actual name of your prime key field?
Is it spelled exactly like that?
Copy and paste your exact code.

Your OpenReport, as written, does not work for me.

If [Dossier] is a Text datatype field try either:

DoCmd.OpenReport stDocName, acViewPreview, , "[Dossier]= '" &
[Dossier] & "'"
Just for clarity that is = ' " & [Dossier] & " ' "
The above will fail if the value of Dossier contains an apostrophe
(').

Or....

DoCmd.OpenReport stDocName, acViewPreview, , "[Dossier] = """ &
[Dossier] & """"
for clarity that is = " " " & [Dossier] & " " " "
Which will work even if the field contains an apostrophe (').

If that doesn't resolve it, I would suspect the problem is a missing
control in the report, not this code to open the report.
 
A

antonov

Fred, I have another question concerning reports:
I need to input same data in the report, nothing that I would like to save
in a table. Once the report is printed I will never use it again. Is it
possible to insert a text box that I can write in directly in the report?
fredg said:
Fred: this is the code as I have written it:

Private Sub ARRIVO_Click()
On Error GoTo Err_ARRIVO_Click

Dim stDocName As String

stDocName = "Arrivo"
DoCmd.OpenReport stDocName, acViewPreview, ,
"[Dossier]=""&[Dossier]&"""

Exit_ARRIVO_Click:
Exit Sub

Err_ARRIVO_Click:
MsgBox Err.Description
Resume Exit_ARRIVO_Click

End Sub

and this is the report's Record Source:
SELECT MAWB.Dossier, MAWB.MAWB, MAWB.AirLineCode, MAWB.Pieces,
MAWB.Weight,
MAWB.CWeight, MAWB.Notified, MAWB.Notes, MAWB.DateOut, MAWB.DateIn,
MAWB.IdConsignee AS MAWB_IdConsignee, Consignee.Consignee, Consignee.Tel,
Consignee.Fax, Consignee_Contatti.IdContatto,
Consignee_Contatti.IDConsignee
AS Consignee_Contatti_IDConsignee, Consignee_Contatti.Contatto,
Consignee_Contatti.Email

fredg said:
On Tue, 22 Nov 2005 21:43:38 +0100, antonov wrote:

Fred, I have tried what you told me (I've changed [RecordID] into
[Dossier]). When I run the event it asks me to enter Parameter
value....
what do I do wrong?
On Tue, 22 Nov 2005 21:13:46 +0100, antonov wrote:

Hello again everybody.
I have created my tables and my forms. I've also created my reports
but
I
cannot get a report to open exactely at the record from which I call
it...
How can I do that?

Your table should have a unique prime key field.

If so, code the command button's Click event:
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If [RecordID] is Text Datatype, then use:

"[RecordID] = '" & [RecordID] & "'"

as the Where clause.
Change the field name to whatever the actual field name is that you
are using.

See Access Help files for:
Where Clause + Restrict data to a subset of records'
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Is [Dossier] the actual name of your prime key field?
Is it spelled exactly like that?
Copy and paste your exact code.

Your OpenReport, as written, does not work for me.

If [Dossier] is a Text datatype field try either:

DoCmd.OpenReport stDocName, acViewPreview, , "[Dossier]= '" &
[Dossier] & "'"
Just for clarity that is = ' " & [Dossier] & " ' "
The above will fail if the value of Dossier contains an apostrophe
(').

Or....

DoCmd.OpenReport stDocName, acViewPreview, , "[Dossier] = """ &
[Dossier] & """"
for clarity that is = " " " & [Dossier] & " " " "
Which will work even if the field contains an apostrophe (').

If that doesn't resolve it, I would suspect the problem is a missing
control in the report, not this code to open the report.
 
F

fredg

Fred, I have another question concerning reports:
I need to input same data in the report, nothing that I would like to save
in a table. Once the report is printed I will never use it again. Is it
possible to insert a text box that I can write in directly in the report?

*** snipped ***

Add an unbound control to the report.
Set it's control source to something like:
=[Write something here]

You will be prompted to enter some text.
 
A

antonov

Thank you very much Fred, you have solved both my problems with the report
(the other one works fine too)
fredg said:
Fred, I have another question concerning reports:
I need to input same data in the report, nothing that I would like to
save
in a table. Once the report is printed I will never use it again. Is it
possible to insert a text box that I can write in directly in the report?

*** snipped ***

Add an unbound control to the report.
Set it's control source to something like:
=[Write something here]

You will be prompted to enter some text.
 
Top