View Full Version : Using Wildcard with stDocName


davea300
08-25-2008, 05:31 AM
I have a report that gets todays date appended to its name every time it is run. I call this report name in a section of code so I need to adjust the reports name everytime I call it.

Is it possible to define stDocName using a wildcard so it will take into account the change of report name each time, something like this:

stDocName = "ReportName*"

giving that "ReportName 25/08/2008" would be an example of the name.

dkinley
08-25-2008, 05:37 AM
Not that I am aware of. You could use something like ...

stDocName = "ReportName " & Date()

-dK

Banana
08-25-2008, 05:37 AM
Use InStr function to see if something is in a string; you also have to loop through possible reports to find what matches and return an array of multiple choice.

See Access help for example on how to use InStr()

HTH.

DJkarl
08-25-2008, 06:11 AM
You could use the Like operator

If "ReportName 25/08/2008" Like "ReportName*" Then
'code here
End If

Banana
08-25-2008, 06:13 AM
Djkarl, funnily enough that was on my tongue, but I never did it in VBA and didn't have Access handy to check so played it safe with Instr(). Glad to know that it can be used in VBA, too. :)

dkinley
08-25-2008, 06:14 AM
I have a report that gets todays date appended to its name every time it is run.

Is it possible to define stDocName using a wildcard so it will take into account the change of report name each time ..

The confusing bit is you are asking two different things; wildcard is used for searches.

However per your example, you are looking to concatenate and come up with a unique name. All these responses will help no matter what is is you are really looking for.

-dK

davea300
08-25-2008, 07:16 AM
The confusing bit is you are asking two different things; wildcard is used for searches.

Thanks, however I wasn't asking two different things. I already knew how to come up with a unique report name for each time it runs.

I have a report that gets todays date appended to its name every time it is run.

This line was intended as a statement. I was only asking how to call this unique name in code. Anyway I have it now so thanks to everyone.

However per your example, you are looking to concatenate and come up with a unique name. All these responses will help no matter what is is you are really looking for.

-dK

davea300
08-25-2008, 07:26 AM
You could use the Like operator

If "ReportName 25/08/2008" Like "ReportName*" Then
'code here
End If

Excellent thanks, looks like just what I'm after :D