Set Database name using no path 
Author Message
 Set Database name using no path

I am using a number of standard data controls to bind DBCombo boxes to
fields and have them filled with the list of data. This all works fine
except that I have browsed to the database with the data control for
the DatabaseName property and again I want to get around having the
database in the specified path.
How can I set the DatabaseName property using no path?
How can I use SQL to select only required data when the RecordSource
has been bound to tables for these DBCombo boxes? - I have tried
putting the SQL in the RecordSource property but this falls over with
required parameter or something. So to get these to work I have bound
the controls to the tables and put the SQL in DBCombo_Click as below:-

Private Sub ADD1_Store_Click(Area As Integer)
Data1.RecordSource = "SELECT STORE.Store_Code FROM STORE WHERE
(STORE.User)=LoggedUser))"
'Data1.Refresh
End Sub

But although the records come back from the table (all records), the
SQL does not refine the search???

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Sat, 29 Dec 2001 03:00:00 GMT  
 Set Database name using no path

Quote:

> I am using a number of standard data controls to bind DBCombo boxes to
> fields and have them filled with the list of data.

How big "a number" of DataControls?  I'm just curious what would take
more than one (or two)?  Are you loading from many different tables?

Quote:
> This all works fine
> except that I have browsed to the database with the data control for
> the DatabaseName property and again I want to get around having the
> database in the specified path.
> How can I set the DatabaseName property using no path?

  A DataControl must have a DatabaseName.  Are you saying you don't want
to hard-code that into the DataControl at design time?  That's cool, but
then you'll have to set it with code at some point...like maybe in the
Form_Open event of the form on which it resides.  Set all the properties
at design time, so you can bind all the Combo Boxes to the correct
fields.  Later, like in Form_Load, you can re-set the DatabaseName - at
that point you'll need to know where the db is, but it's not clear to me
where that is?  If the db will always be installed in same folder as
your app, then you can say:

 Data1.DatabaseName = App.Path & "\ThisHere.mdb"

  If you don't know where your target machine will have the db file,
then ya got a bit more work to look it up first...ya didn't ask how to
do that (yet).

Quote:
> How can I use SQL to select only required data when the RecordSource
> has been bound to tables for these DBCombo boxes? - I have tried
> putting the SQL in the RecordSource property but this falls over with
> required parameter or something.

From the code you gave, it looks like you're trying to select only
records where STORE.User = LoggedUser.  Somehow, you're assigning a
value to LoggedUser, which I assume is a text string like a name.  So,
you could add the following line in the Form_Load (or where ever), right
after the DatabaseName line above:

 Data1.RecordSource = "SELECT Store_Code FROM STORE WHERE User='" &
LoggedUser & "'"

 I dropped the more explicit references to the STORE table fields, since
all I see open is the one table for this DataControl - you can use 'em
if ya wanna, but it should work w/o.
  Now, I don't know by what method you're filling the ComboBoxes - in
the code I cribbed from you, you're only retrieving one field,
Store_Code - are you putting that in a ComboBox?
  Anyway, if you set the Data1's DbName and RecordSource in the
Form_Open of the form it's on, the DataControl will get its data using
these properties (regardless of what was originally set at design time),
and your form should open up displaying only the record(s) for
LoggedUser's store.
  If this is any help, but you have other questions, please try me
again.
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"

"What's so funny 'bout peace, love & understanding?"
     - Nick Lowe



Sat, 29 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Set Database Name property using no path

2. Setting FileListBox.Path and Naming New Program Items

3. Retrieving Full Database Path Name

4. Current database path name

5. Path names in a database problem

6. Passing Database name and path

7. Picking up path name of Access Database

8. Setting Path to Access Database

9. Setting Path to Access Database

10. Setting path to database from text file ??

11. How to set path for database (.mdb) file ???

12. Set Database path

 

 
Powered by phpBB® Forum Software