Awes
Usually Confused
- Local time
- Today, 12:02
- Joined
- Aug 20, 2002
- Messages
- 34
I am developing a form where eventually the user enters a surname into a combobox 'FindSurname' on the form, which is based on a query, and then clicks on a button 'Select'. This will then run some code and the, display all occurences of the selected surname in a subform 'subCustDets', which is set up to display in datasheet view.
As I haven't done this before I am building the form up slowly so
that any problems that occur are easier to find and correct.
To start with all I want to do is click on the 'Select' button, to
run the code, and display all the records from the table containing
the names 'T_Customers' which has the following fields:
Cust_Id
Title
Initial
Surname
The code I'm using is as follows:
Dim MyDb As Database
Dim Recset As Recordset
Set MyDb = CurrentDb
Set Recset = MyDb.OpenRecordset("SELECT ALL T_Customers.Cust_ID, " & _
"T_Customers.Title, T_Customers.Initial, T_Customers.Surname " & _
"FROM T_Customers")
Me!subCustDets!Cust_ID = Recset!Cust_ID
Me!subCustDets!Title = Recset!Title
Me!subCustDets!Initial = Recset!Initial
Me!subCustDets!Surname = Recset!Surname
The result is that the subform displays the first record from the
table 'T_Customers' but none of the other records, currently 9.
What am I doing wrong??
To complete the process what form should the WHERE element of the query take place so that it gets the name entered into 'FindSurname' and only displays the matching records in the subform??
I think it should be:
.....FROM T_Customers WHERE T_Customers.Surname = Me!FindSurname
but would like somebody to confirm that for me.
Many thanks for taking an interest and for any feedback you provide.
As I haven't done this before I am building the form up slowly so
that any problems that occur are easier to find and correct.
To start with all I want to do is click on the 'Select' button, to
run the code, and display all the records from the table containing
the names 'T_Customers' which has the following fields:
Cust_Id
Title
Initial
Surname
The code I'm using is as follows:
Dim MyDb As Database
Dim Recset As Recordset
Set MyDb = CurrentDb
Set Recset = MyDb.OpenRecordset("SELECT ALL T_Customers.Cust_ID, " & _
"T_Customers.Title, T_Customers.Initial, T_Customers.Surname " & _
"FROM T_Customers")
Me!subCustDets!Cust_ID = Recset!Cust_ID
Me!subCustDets!Title = Recset!Title
Me!subCustDets!Initial = Recset!Initial
Me!subCustDets!Surname = Recset!Surname
The result is that the subform displays the first record from the
table 'T_Customers' but none of the other records, currently 9.
What am I doing wrong??
To complete the process what form should the WHERE element of the query take place so that it gets the name entered into 'FindSurname' and only displays the matching records in the subform??
I think it should be:
.....FROM T_Customers WHERE T_Customers.Surname = Me!FindSurname
but would like somebody to confirm that for me.
Many thanks for taking an interest and for any feedback you provide.