Report for current client

E

Emma

Hello I am trying to create a report which only opens the current client, I'm
using the following however there is a space in Client ID so I'm not sure how
to write this?

Private Sub Report_Load()
DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = " & Me.Client_ID
End Sub

I'm sure there is a simple answer to this, thanks
 
B

BruceM

If there is a space, include the field or control name in square brackets.
Substituting the underscore for the space will not work, as Access
recognizes it as a completely different character than the space.
 
M

Maverick

I'm not sure what the problem is. It looks like the code you wrote should
work. The only question I have is why you are calling this from the On Load
event of the report. You should put this code on the button or whatever
source you use to open the report.

Is the code you wrote giving you an error?
 
K

Klatuu

The code is in the wrong place. It should be in the click event of a command
button on a form.

When one reads ClientID, the inclination it is is a numeric field, likely an
Autonumber, but you say there is a space in it, so that means either it has
to be a text field, or you are confused. So, you have to use the correct
syntax for text fields:

DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = """ & Me.Client_ID & """"
 
B

BruceM

Oops, I assumed the event was a command button, and didn't notice that the
posted code is in the Load event. To the OP, the underscore and the space
are different characters. You are using both in the code you posted. Did
you mean to do that, or is there just one field name?

Maverick said:
I'm not sure what the problem is. It looks like the code you wrote should
work. The only question I have is why you are calling this from the On
Load
event of the report. You should put this code on the button or whatever
source you use to open the report.

Is the code you wrote giving you an error?

Emma said:
Hello I am trying to create a report which only opens the current client,
I'm
using the following however there is a space in Client ID so I'm not sure
how
to write this?

Private Sub Report_Load()
DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = " & Me.Client_ID
End Sub

I'm sure there is a simple answer to this, thanks
 
M

Maverick

I think Emma was referring to the name of the field having a space in it, not
the data itself. However, having the field name in hard brackets would solve
this problem.

Klatuu said:
The code is in the wrong place. It should be in the click event of a command
button on a form.

When one reads ClientID, the inclination it is is a numeric field, likely an
Autonumber, but you say there is a space in it, so that means either it has
to be a text field, or you are confused. So, you have to use the correct
syntax for text fields:

DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = """ & Me.Client_ID & """"


--
Dave Hargis, Microsoft Access MVP


Emma said:
Hello I am trying to create a report which only opens the current client, I'm
using the following however there is a space in Client ID so I'm not sure how
to write this?

Private Sub Report_Load()
DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = " & Me.Client_ID
End Sub

I'm sure there is a simple answer to this, thanks
 
E

Emma

Yes that did answer my question, thanks for explaining about clicking on a
button
a
Maverick said:
I think Emma was referring to the name of the field having a space in it, not
the data itself. However, having the field name in hard brackets would solve
this problem.

Klatuu said:
The code is in the wrong place. It should be in the click event of a command
button on a form.

When one reads ClientID, the inclination it is is a numeric field, likely an
Autonumber, but you say there is a space in it, so that means either it has
to be a text field, or you are confused. So, you have to use the correct
syntax for text fields:

DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = """ & Me.Client_ID & """"


--
Dave Hargis, Microsoft Access MVP


Emma said:
Hello I am trying to create a report which only opens the current client, I'm
using the following however there is a space in Client ID so I'm not sure how
to write this?

Private Sub Report_Load()
DoCmd.OpenReport "Individual Case Note Report", acViewPreview, , "[Client
ID] = " & Me.Client_ID
End Sub

I'm sure there is a simple answer to this, thanks
 
Top