PDA

Click to See Complete Forum and Search --> : Problem similar to Harrild's....


FLL
Jul 11th, 2000, 11:36 PM
Hello, all. I posted a question last night that was answered by a user, but it didn't seem to work. After reading Harrild's message, it seems my problem is similar. I am hoping that you can tell me what the coding flaw is in this project...it's a contact management system, and I want to populate the text boxes at runtime because I want a command button to execute the search...

I'm using a dataenvironment, and when I use the drag and drop to put the text boxes on the form from the data environment, it populates perfectly (of course!), but I want to execuate Command1's SQL statement from code because I am going to use a form that will allow the user to query on specific criteria, but here is the problem: When I just add normal text boxes to a form, create a data environment, and then try to populate the text boxes at run time, I keep getting a bugging error that

Text1.DataSource = RecordSet

is not valid. Here is a sample of code I have used:

Private Sub Command1_Click()
DataEnvironment1.Commands("Command1").CommandText = "Select * From Customers"
DataEnvironment1.Command1
Text2.DataSource = rsCommand1
Text2.DataField = "ContactName"
End Sub

1) I don't have a specific command specified in the SQL window of the data environment. Is this a problem? If so, how can i get around this at runtime, because I am actually going to set the SQL command as a string to allow the user to specify his/her own criteria

2) Should this code not bind the data environment to the text box?

Where is the flaw in this code? Relatively simple, but really having me pulling my hair out! This misunderstanding of how the data environment works is holding up the project...and I need to use the data environment (I can get it to work using ADO straight coding) because I need to access the data report designer...

Any help would be greatly appreciated...

Thanks..FLL