Question on Code

P

pam

DoCmd.OpenReport "DIA",acViewPreview , , "[Country]='" & Me![Combo59] & "'"


If my Country was changed to ID Number which is a number where do i take out
quotes, and what will the code look like
 
C

Cheval

You only need quotes (single or double double) when you
are filtering a text field. eg Country.

DoCmd.OpenReport "DIA",acViewPreview , , "[Country]=""" &
Me![Combo59] & """"

ID Answer
DoCmd.OpenReport "DIA",acViewPreview , , "CountryID=" & Me!
[Combo59]

The other thing, it's always best to rename your controls
from the default to make programming life easier. eg.
Combo59 to cboCountry. Also use dot notation to catch any
errors at design time eg.

DoCmd.OpenReport "DIA",acViewPreview , , "CountryID=" &
Me.cboCountry
 
P

pam

Here is my code and it doesnt appear to work:

DoCmd.OpenReport "JPMC", acViewPreview, , [UserOrgId]= & Me![Combo14] & "'"

What could be wrong


Cheval said:
You only need quotes (single or double double) when you
are filtering a text field. eg Country.

DoCmd.OpenReport "DIA",acViewPreview , , "[Country]=""" &
Me![Combo59] & """"

ID Answer
DoCmd.OpenReport "DIA",acViewPreview , , "CountryID=" & Me!
[Combo59]

The other thing, it's always best to rename your controls
from the default to make programming life easier. eg.
Combo59 to cboCountry. Also use dot notation to catch any
errors at design time eg.

DoCmd.OpenReport "DIA",acViewPreview , , "CountryID=" &
Me.cboCountry
-----Original Message-----
DoCmd.OpenReport "DIA",acViewPreview , , "[Country]='" & Me![Combo59] & "'"


If my Country was changed to ID Number which is a number where do i take out
quotes, and what will the code look like
.
 
R

Reggie

Pam, assuming UserOrgID is a number change it to
DoCmd.OpenReport "JPMC", acViewPreview, , "[UserOrgId]=" & Me![Combo14]

Hope this helps!

Reggie

Here is my code and it doesnt appear to work:

DoCmd.OpenReport "JPMC", acViewPreview, , [UserOrgId]= & Me![Combo14] & "'"

What could be wrong


:

You only need quotes (single or double double) when you
are filtering a text field. eg Country.

DoCmd.OpenReport "DIA",acViewPreview , , "[Country]=""" &
Me![Combo59] & """"

ID Answer
DoCmd.OpenReport "DIA",acViewPreview , , "CountryID=" & Me!
[Combo59]

The other thing, it's always best to rename your controls
from the default to make programming life easier. eg.
Combo59 to cboCountry. Also use dot notation to catch any
errors at design time eg.

DoCmd.OpenReport "DIA",acViewPreview , , "CountryID=" &
Me.cboCountry

-----Original Message-----
DoCmd.OpenReport "DIA",acViewPreview , , "[Country]='" &

Me![Combo59] & "'"
If my Country was changed to ID Number which is a number

where do i take out
quotes, and what will the code look like
.
 

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