sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
S. van Beek's Avatar

CompactDatabase command with variables


Question posted by: S. van Beek (Guest) on November 13th, 2005 05:03 AM
Dear reader,

By using the CompactDatabase command I discovered the following unpleasant
situation:

DBEngin.CompactDatabase "DB_a", "DB_b"

The above sentence works perfect, but if I will use the command with
variables from a table it fails, for instance:

DBEnging.ComandDatabase Rst1!DB_old , Rst1!DB_new

The same negative result is by using this commend with string variables as:

Dim DB_a as String
Dim DB_b as String
Dim Rst1 as DAO.Recordset

Set Rst1 = db.OpenRecordset("Tbl_Databases")

DB_a = Rst1!DB_old (fieldname from the table)
DB_b = Rst1!DB_new

DBEnging.ComandDatabase DB_a , DB_b

This instruction set is also not working.

Tanks for any help to solve this situation

Kind regards,
Simon van Beek


1 Answer Posted
Douglas J. Steele's Avatar
Douglas J. Steele November 13th, 2005 05:03 AM
Guest - n/a Posts
#2: Re: CompactDatabase command with variables

What error do you get? Are you sure that both Rst1!DB_old and Rst1!DB_new
are valid file names? Do they contain blanks? If so, you need to put quotes
around them:

DBEngine.CompactDatabase Chr$(34) & DB_a & Chr$(34) , Chr$(34) & DB_b
& Chr$(34)


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"S. van Beek" <S.v,Beek@HCCnet.nl> wrote in message
news:4186a919$0$773$3a628fcd@reader20.nntp.hccnet. nl...[color=blue]
> Dear reader,
>
> By using the CompactDatabase command I discovered the following unpleasant
> situation:
>
> DBEngin.CompactDatabase "DB_a", "DB_b"
>
> The above sentence works perfect, but if I will use the command with
> variables from a table it fails, for instance:
>
> DBEnging.ComandDatabase Rst1!DB_old , Rst1!DB_new
>
> The same negative result is by using this commend with string variables[/color]
as:[color=blue]
>
> Dim DB_a as String
> Dim DB_b as String
> Dim Rst1 as DAO.Recordset
>
> Set Rst1 = db.OpenRecordset("Tbl_Databases")
>
> DB_a = Rst1!DB_old (fieldname from the table)
> DB_b = Rst1!DB_new
>
> DBEnging.ComandDatabase DB_a , DB_b
>
> This instruction set is also not working.
>
> Tanks for any help to solve this situation
>
> Kind regards,
> Simon van Beek
>
>[/color]


 
Not the answer you were looking for? Post your question . . .
196,873 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,873 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors