Code:
Dim cstsname As String Dim cstpc As String Dim rstresult As Recordset 'recordset to store output Dim mydatabase As Database 'Variable to store user entered surname Me.Text20.SetFocus cstsname = Text20.Text 'Variable to store user entered postcode Me.Text22.SetFocus cstpc = Text22.Text 'sql statement to select from customer table Set mydatabase = CurrentDb Set rstresult = mydatabase.OpenRecordset( _ "SELECT CustomerID, CustomerForename, CustomerSurname, CstPostcode FROM tblcustomer WHERE CustomerSurname = '" & cstsname & "' AND CustPostcode = '" & cstpc & "'", dbOpenDynaset, dbReadOnly)
Comment