FoxProProgrammer
Programmer
I am developing a form with a combo box and several text boxes. The name of the form is ManufDetails. The combo box contains a list of manufacturer's names and the text boxes contain the manufacturer's address, city, state, zip, POC, etc. When the user selects a manufacturer from the combo box, I want the contact information in the text boxes to update.
The form's Record Source is set to a Query. It is a long string, but the gist of it is shown below.
SELECT Manufacturers.street, Manufacturers.city,Manufacturers.state,...FROM....WHERE Manufacturers.manufacturer = forms!formname!controlname.value
controlname in the WHERE clause is the name of the combo box.
The On Change event procedure for the combo box contains the statement:
Forms!ManufDetails.Requery
I thought that this would execute the form's Query. Well, the text boxes on the form don't update when the program runs. I ran it in debug mode to make sure that the On Change procedure runs and the Requery statement executes. No problem there.
Here's a fundamental question that might help me figure this out. The text boxes on the form are bound. How do I know if they are bound to the table or the query? I assume that since the form's Record Source is a Query, the forms controls are bound to that Query and not to the underlying table. Also, how can I see the data that comes back from a Query? This might help me troubleshoot the problem. I created a watch variable for "Recordset" in the VB debugger. Is the data that I'm looking for in this object? I couldn't find it, but there are a lot of things in that object.
I have another form that has a similar problem, although it has more than one combo box that must be updated based on the contents of another combo box. Hopefully I can get it to work after I figure out what's wrong with this on one.
BTW, I did get this to work using a different method as shown below:
Sub ManufName_Change()
dim strManufName as String
dim strQuery as String
strManufName = ManufName.Value
strQuery = "SELECT Manufacturers.Street, Manufacturers.City, ... FROM ...INNER JOIN.... WHERE (Manufacturers.Manufacturer) = ' " & strManufName & " ' ORDER BY...
RecordSource = strQuery
When I run this code, the text boxes update correctly. I understand that changing the record source of an open form causes a requery. That explains why this code works, but it doesn't explain why the Requery method doesn't work. I think the Requery code is cleaner because there's no reason to change the record source every time the user clicks in the combo box. The SELECT statement is constant. Only the contents of the variable in the WHERE clause changes.
Thanks for any help.
dz
The form's Record Source is set to a Query. It is a long string, but the gist of it is shown below.
SELECT Manufacturers.street, Manufacturers.city,Manufacturers.state,...FROM....WHERE Manufacturers.manufacturer = forms!formname!controlname.value
controlname in the WHERE clause is the name of the combo box.
The On Change event procedure for the combo box contains the statement:
Forms!ManufDetails.Requery
I thought that this would execute the form's Query. Well, the text boxes on the form don't update when the program runs. I ran it in debug mode to make sure that the On Change procedure runs and the Requery statement executes. No problem there.
Here's a fundamental question that might help me figure this out. The text boxes on the form are bound. How do I know if they are bound to the table or the query? I assume that since the form's Record Source is a Query, the forms controls are bound to that Query and not to the underlying table. Also, how can I see the data that comes back from a Query? This might help me troubleshoot the problem. I created a watch variable for "Recordset" in the VB debugger. Is the data that I'm looking for in this object? I couldn't find it, but there are a lot of things in that object.
I have another form that has a similar problem, although it has more than one combo box that must be updated based on the contents of another combo box. Hopefully I can get it to work after I figure out what's wrong with this on one.
BTW, I did get this to work using a different method as shown below:
Sub ManufName_Change()
dim strManufName as String
dim strQuery as String
strManufName = ManufName.Value
strQuery = "SELECT Manufacturers.Street, Manufacturers.City, ... FROM ...INNER JOIN.... WHERE (Manufacturers.Manufacturer) = ' " & strManufName & " ' ORDER BY...
RecordSource = strQuery
When I run this code, the text boxes update correctly. I understand that changing the record source of an open form causes a requery. That explains why this code works, but it doesn't explain why the Requery method doesn't work. I think the Requery code is cleaner because there's no reason to change the record source every time the user clicks in the combo box. The SELECT statement is constant. Only the contents of the variable in the WHERE clause changes.
Thanks for any help.
dz