Open Report From Form With Wildcard

P

PHisaw

Hi,
I use the following code to open and print reports in the AfterUpdate event.
Works well, now users want to be able to use same report with any entry for
Smith in CustomerName field. Example: Smith, A or Smith, John. How do I
use a wildcard in code to pull all entries for Smith*?

If Me.Parent!CustomerName = "Smith" Then
DoCmd.OpenReport "SmithJobs"

Thanks in advance for any help,
Pam
 
D

DoveArrow

Hi,
I use the following code to open and print reports in the AfterUpdate event.
Works well, now users want to be able to use same report with any entry for
Smith in CustomerName field. Example: Smith, A or Smith, John. How do I
use a wildcard in code to pull all entries for Smith*?

If Me.Parent!CustomerName = "Smith" Then
DoCmd.OpenReport "SmithJobs"

Thanks in advance for any help,
Pam

I'm assuming that your report is pulling data from a query. If that's
the case, you could put the following code in the Criteria area:

Like "Smith" & "*"

Or

Like [Enter Customer Last Name] & "*"

Hope this helps.
 
P

PHisaw

DoveArrow,
Thank you for replying. I realize I can put this in the criteria area of
the query, but what will then trigger the report when the customer name is
selected in the combo box. I want this to be automatic when user types in
any variation of the customer name. Do you have any other suggestions?
Thanks,
Pam

DoveArrow said:
Hi,
I use the following code to open and print reports in the AfterUpdate event.
Works well, now users want to be able to use same report with any entry for
Smith in CustomerName field. Example: Smith, A or Smith, John. How do I
use a wildcard in code to pull all entries for Smith*?

If Me.Parent!CustomerName = "Smith" Then
DoCmd.OpenReport "SmithJobs"

Thanks in advance for any help,
Pam

I'm assuming that your report is pulling data from a query. If that's
the case, you could put the following code in the Criteria area:

Like "Smith" & "*"

Or

Like [Enter Customer Last Name] & "*"

Hope this helps.
 
D

DoveArrow

DoveArrow,
Thank you for replying. I realize I can put this in the criteria area of
the query, but what will then trigger the report when the customer name is
selected in the combo box. I want this to be automatic when user types in
any variation of the customer name. Do you have any other suggestions?
Thanks,
Pam



I'm assuming that your report is pulling data from a query. If that's
the case, you could put the following code in the Criteria area:
Like "Smith" & "*"

Like [Enter Customer Last Name] & "*"
Hope this helps.- Hide quoted text -

- Show quoted text -

So if I'm understanding you correctly, you have a combo box on a form
that you're entering this information into? If that's the case, try
putting the following into the criteria of the query that your report
is based on:

Like [Forms]![FormName]![ComboBoxName] & "*"

Of course, replace [FormName] and [ComboBoxName] with the name of your
form and Combo Box. However, this should do what you want. The only
concern that I would have is that if you type 'Smith, Albert,' it will
bring up 'Smith, Alberto,' and 'Smith, Alberta' as well. If that's
okay with you, this should be all you need. I hope this helps.
 

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