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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Control

Status
Not open for further replies.

elziko

Programmer
Nov 7, 2000
486
GB
I have a combobox (Database), a data control (ConnectedDatabase) and a text box (ConnectedField).

I am trying to write a sub that will look up correct details from an INI file based on the contents of the combobox and using these details I want to set the DatabaseName and RecordSource properties of the data control before setting the DataField property of the text box. ie. I want to display the values of a certain field from a certain database in the text box.

So I wrote this:

Private Sub Refresh_Records()
ConnectedDatabase.DatabaseName = GetFromINI(INILoc, Database.List(Database.ListIndex), "Database")
ConnectedDatabase.RecordSource = GetFromINI(INILoc, Database.List(Database.ListIndex), "Table")
ConnectedField.DataField = GetFromINI(INILoc, Database.List(Database.ListIndex), "IndexField")
End Sub

This works fine when called upon a FormLoad event but not upon the combo box Click event. If I try running from the Click event I get the error:

"Unable to bind field: 'thefield'"

What am I doing wrong to make it work only under some events?

Thanks
 
I've got a similar problem. I'm halfway there using your control names I added in a ConnectedDatabase.refresh after the record source method. Mine now says that it doesn't support this method but after you click OK it works fine. But I do have to click OK every time.

If anyone can help us further?????

Thanx
 
Sorry I'm confused. The afterupdate event of which control?? I'm selecting which database to be connected to using the combo box which tells the datacontrol which database, table and then tells the textbox which field to look at.

I cant run the above code from the afterupdate event because the combobox doesn't have one!

Incidently, qwerty, I also tried what you did with the same results.

Thanks

elziko
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top