bpcslave 0 Newbie Poster

Good evening, all...

Quick question, wonder if any light can be shed. I'm running a two-form program that reads from a database with three tables - first form has a filelist box that lists the available databases, the form takes that filename and uses it to set the source for ADODC data controls, so essentially you can choose which database to be reading from on the first page (important as my program is an "interactive fiction" gamebook that lets you choose from different stories (pre-written databases)).

When the second form (where the game itself is displayed) loads, it calls a procedure that changes the connection string to read from app.path & the database filename, then sets the datasource for all of the labels to their respective data controls, so far, no problems.

I was having some problems with it updating a boolean field in the database to mark whether an "encounter" (monster / pickup / treasure etc) has been visited, to avoid it popping up each time you enter a location. I'll be honest, I hadn't coded VB until about eight months ago and I was having problems with getting the ADODC objects to write to the database... so I cheated, put in a basic data object linked to a checkbox (chkDone) and linked label called lblEncTally to keep track of which ID line it was reading - then called the following after each encounter:

datEncDone.Recordset.MoveFirst
Do Until Val(lblEncTally.Caption) = Val(lblEncTest.Caption)
datEncDone.Recordset.MoveNext
lblEncTally.Refresh
Loop
chkDone.Value = 1

Crude, but effective. When the encounter was done, the data object would cycle through until the lblEncTally value was the same as the lblEncTest (which displayed the number of the encounter, for testing purposes), it would check the box, and thereby edit the database. Worked fine, not a problem. I've never used ADODC before and because of time constraints I had to go with what I knew.

I also have a hidden database called Default.mdb, that the datasources point to initially to display a welcome message and default field values, but the filelist is set to ignore hidden files, so it'll never be picked by mistake and will always be supplanted by a "real" database (the button to proceed is inactive until the user clicks a filename). I've made test readouts to check which database is being read from by all the controls, without variation it's the one I choose at the filelist box. I did have to put in a routine that would set the datasource for all the labels again when the second form loads because they appeared to be reading from the default.mdb depite the data controls being set to read from the new database. I went to try to set the labels to read from the data object, but it comes up with a type mismatch error, hovering over it in debug mode shows that it's trying to read the caption rather than the object name (see attached screenie). I've got 14 records in the Encounters table, but when I make the data object and lblEncTally visible to bughunt, cycling through stops at 12, meaning that when I try to invoke encounter 13 it throws up errors about records not found. I think the Default.mdb that I'm using for testing and as a template has 12 records, so it's sticking with that, annoyingly.

So, to cut a long story short (too late!) - is there a way to set the DataSource property from a label to make sure it's pointing at the data object rather than its caption? Is there something obvious I'm missing? Any suggestions? Not asking for a walkthrough as this is something I want to bash out on my own, but right now I feel like I'm running against a brick wall...