Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data control database name

Status
Not open for further replies.

ycim

Programmer
Feb 9, 2005
95
CA
When using a data control, I find that I have to specify the database name. The directory for my computer will obviously not be the same directory for a computer that the program will ultimately be installed on.

I know that I can set this through the code using app.path, but this does not help me set the properties of a particular object at design time.

If one is designing an application for distribution, how would you specify the database name for a data control?

Or am I missing something here???

Thanks a bunch!
 
I always "hard-code" the App.Path. It's not the best way, but I never encountered problems 'cause my setup makes sure that the user cannot change the installationpath. If the user relocates the folder... then he's in trouble... ;)
 
You should allow for the user to select the DATA directory and the PROGRAM directory at will, but defaulting the PROGRAM to the standard "program files" (not hardcoded, but the correct "environment" variable).


So as part of yor setup/configuration you ask for both those folders, and then store them in a registry/ini file, and then use those values to open and access your database(s).


As for setting the variable for a particular control, I assume that you are using Bound controls. DON'T. search tek-tips/"the net" for bound vs unbound and you will see what I mean.

But regardless of that, every control/object that allows you to define a connection will work in one of two ways.
1- Connection is a string variable. this is the case for example of the ADODB.connection object.
Here you just set this string dynamically e.g. myadoconn.connectionstring = my_registry_folder_location_and_other_connection_values

2- Connection is a data provider object.
Nothing to do here. Connection string will be part of the data provider object, and it is on that one that the string must be set. e.g. point 1.





Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
I have always programmed for local business and not for global distribution. So with a career change also comes new knowledge. I am not certain yet how to play with the registry values, so I will certainly keep this in mind when I get there. It is a good idea, however.

Let me backtrack a bit on the other issue. I am not using bound controls. I have done this route, and thanks to the great people on tek-tips, I learned my lesson quickly.

But I am doing the transition from VBA to VB. Access is a world where most of the connections are done for you, so to have to do it all manually is a steep learning curve. One of the challenges I am facing is multiple column combo controls. I have read, through this forum, that using the combo with the Forms 2.0 reference can create a similar combo to the one in Access. I cannot, however, seem to get it working unless I use a data control.

So, the simplest answer I am looking for is....what is the best way to get a multiple column combo box without connecting directly to a data control? And, if there is any experience with the combo box from the Forms 2.0 reference, advise would be good!
 
Just to verify...here is the code that I am applying.

To open the recordset...(this is working fine)
Code:
    Dim rstNames As New ADODB.Recordset
    Set rstNames = New ADODB.Recordset
    strSQL = "Select namesid,name from tblinfonames"
    With rstNames
        .Open strSQL, cCn, adOpenStatic, adLockOptimistic
    End With
To apply the datasource...
Code:
 With Me.cboNames
        .DataSource = rstNames
        .BoundColumn = "namesid"
 End With
The problem, right off the bat, is that .datasource is giving me a "method or data member not found" error.

If there is another way of attacking this, input would be appreciated.
 
what is the "me" object? not all objects have that property, and normally the "me" relates to a form object, not to a combo box which seems to be what you wish to have loaded.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
That is just referring to the form. Whether I use the me. or leave it out, the exact same behaviour happens.
 
A datasource needs to be an object. Your construct

.DataSource = rstNames

is attempting to set the recordset's default property (the fields collection) to the DataSource. You need

SET .DataSource = rstNames
 
OI OI OI OI OI....
That was SO simple! How did I miss that!

Thank you very much!
 
The combo box from FORMS 2.0 has a controlsource property. so try

With Me.cboNames
.controlsource = rstNames
.BoundColumn = "namesid"
End With


Note that I have never uses FORMS so I don't know how to solve your exact problem.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks...I will try this approach as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top