PC Review


Reply
Thread Tools Rate Thread

Using a variable in Access 2000

 
 
Del
Guest
Posts: n/a
 
      9th Jul 2008
I want to use code for the row source of a combo box to fill its list with
tables from a different database. The following code works if I have the
unique path 'C:\MyFolder\MyFile.mdb' included.

SELECT MSysObjects.[Name]
FROM MSysObjects IN 'C:\MyFolder\MyFile.mdb'
WHERE (MSysObjects.[Type] = 1)
AND NOT ((MSysObjects.[Name] Like "MSys*"))
ORDER BY MSysObjects.[Name];

But when I replace the unique path with the variable strPath, Access sees
the path with a back slash and the variable on the end. I get the following
message: Could not find the file 'C:\MyFolder\MyFile.mdb\strPath'

What is the correct syntax to replace the unique path with a variable?
--
Thank you,
Del
 
Reply With Quote
 
 
 
 
Klatuu
Guest
Posts: n/a
 
      9th Jul 2008
Would help if you post the code that isn't working so we can see what the
problem is.
--
Dave Hargis, Microsoft Access MVP


"Del" wrote:

> I want to use code for the row source of a combo box to fill its list with
> tables from a different database. The following code works if I have the
> unique path 'C:\MyFolder\MyFile.mdb' included.
>
> SELECT MSysObjects.[Name]
> FROM MSysObjects IN 'C:\MyFolder\MyFile.mdb'
> WHERE (MSysObjects.[Type] = 1)
> AND NOT ((MSysObjects.[Name] Like "MSys*"))
> ORDER BY MSysObjects.[Name];
>
> But when I replace the unique path with the variable strPath, Access sees
> the path with a back slash and the variable on the end. I get the following
> message: Could not find the file 'C:\MyFolder\MyFile.mdb\strPath'
>
> What is the correct syntax to replace the unique path with a variable?
> --
> Thank you,
> Del

 
Reply With Quote
 
Marshall Barton
Guest
Posts: n/a
 
      9th Jul 2008
Del wrote:

>I want to use code for the row source of a combo box to fill its list with
>tables from a different database. The following code works if I have the
>unique path 'C:\MyFolder\MyFile.mdb' included.
>
> SELECT MSysObjects.[Name]
> FROM MSysObjects IN 'C:\MyFolder\MyFile.mdb'
> WHERE (MSysObjects.[Type] = 1)
> AND NOT ((MSysObjects.[Name] Like "MSys*"))
> ORDER BY MSysObjects.[Name];
>
>But when I replace the unique path with the variable strPath, Access sees
>the path with a back slash and the variable on the end. I get the following
>message: Could not find the file 'C:\MyFolder\MyFile.mdb\strPath'



strSQL = "SELECT MSysObjects.[Name] " _
& "FROM MSysObjects " _
& "IN 'C:\MyFolder\" & strPath & "' " _
& "WHERE (MSysObjects.[Type] = 1) " _
& "AND NOT MSysObjects.[Name] Like "MSys*" " _
& "ORDER BY MSysObjects.[Name]"

--
Marsh
MVP [MS Access]
 
Reply With Quote
 
Del
Guest
Posts: n/a
 
      9th Jul 2008
I put following in a module I call modVariables: Public strPath as String

I set strPath to the user entered path of the different database

I put the following code in the Row Source of a combo box to fill its list
with the tables in the different database. This code does not work.

SELECT MSysObjects.[Name]
FROM MSysObjects IN strPath
WHERE (MSysObjects.[Type] = 1)
AND NOT ((MSysObjects.[Name] Like "MSys*"))
ORDER BY MSysObjects.[Name];

If I replace the variable strPath with the actual path it works. Ref below:

SELECT MSysObjects.[Name]
FROM MSysObjects IN 'C:\MyFolder\MyFile.mdb'
WHERE (MSysObjects.[Type] = 1)
AND NOT ((MSysObjects.[Name] Like "MSys*"))
ORDER BY MSysObjects.[Name];

--
Thank you,
Del


"Klatuu" wrote:

> Would help if you post the code that isn't working so we can see what the
> problem is.
> --
> Dave Hargis, Microsoft Access MVP
>
>
> "Del" wrote:
>
> > I want to use code for the row source of a combo box to fill its list with
> > tables from a different database. The following code works if I have the
> > unique path 'C:\MyFolder\MyFile.mdb' included.
> >
> > SELECT MSysObjects.[Name]
> > FROM MSysObjects IN 'C:\MyFolder\MyFile.mdb'
> > WHERE (MSysObjects.[Type] = 1)
> > AND NOT ((MSysObjects.[Name] Like "MSys*"))
> > ORDER BY MSysObjects.[Name];
> >
> > But when I replace the unique path with the variable strPath, Access sees
> > the path with a back slash and the variable on the end. I get the following
> > message: Could not find the file 'C:\MyFolder\MyFile.mdb\strPath'
> >
> > What is the correct syntax to replace the unique path with a variable?
> > --
> > Thank you,
> > Del

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up a Global Variable / Access 2000 Abay Microsoft Access Forms 2 25th Apr 2007 04:45 AM
Sql Server 2000 (NEW SP4 installed) Access ADO EXEC call fails when variable names are passed DaveSwain Microsoft Access 1 15th Jan 2007 06:47 PM
VBA Access - Moving parts of a program to DLLs? Error 91.. "Object variable or With block variable not set" axs221 Microsoft Access 10 25th Jul 2006 01:53 PM
Convert Excel variable to Access variable =?Utf-8?B?QW5keQ==?= Microsoft Access VBA Modules 4 17th Mar 2006 01:57 AM
Access 2002 queries saved as 2000 do not show in access 2000 =?Utf-8?B?Q2xhdWRl?= Microsoft Access 0 6th Jan 2004 04:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:40 PM.