Removing characters from a query name

  • Thread starter Thread starter Tony
  • Start date Start date
T

Tony

Hi Group,

It would be great if someone could help me here.
How do I remove, using VBA, the <> tags and spaces from
<Calendar Of Events> to show CalendarofEvents.

Thanks

Tony
 
Assuming you're using Access 2000 or newer, you can use the Replace
function.

I'm not quite sure I understand what you're trying to do, though, so I can't
offer an exact example. Do you mean you want to change the name of a query
from <Calendar Of Events> to CalendarOfEvents?

If so, try

Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef

Set dbCurr = CurrentDb()
Set qdfCurr = dbCurr.QueryDefs("<Calendar Of Events>")
qdfCurr.Name = Replace(Replace(Replace("<Calendar Of Events>", "<", ""),
">", ""), " ", "")

(although you'd probably use qdfCurr.Name = "CalendarOfEvents" in that
example!)

Note that the code above uses DAO. You'll need to set a reference to DAO if
you don't already have one in your application.
 
Hi Douglas,

Thanks for your reply.
Apoogies for not being more detailed - I was trying to be
brief as possible.
The <Calendar Of Events> is actually the name of a query,
and there are others in the same format, i.e. <Promotions
And Events>.
Forms based on these queries are named frmCalendarOfEvents
and frmPromotionsAndEvents, etc.
I have built a search form, where the user selects the
query from a combo box, performs criteria search which, in
turns, creates a SQl Where string. I would like to pass
this string to the appropriate form and open it hence the
need to remove <> tags and spaces (code below)
Hope this provides enough info.

Regards

Tony

Dim stDocName As String
stDocName = "frm" & Me!lstTables
DoCmd.OpenReport stDocName, acViewPreview, ,
strReportWhere
 
Back
Top