Form based on recordset limited to one record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to limit this recordset to one record selected based on the social
security number from another form. However, when I use the following where,
it gives me an error.
Dim workbase As CurrentProject
Dim cn As ADODB.Connection
Set cn = CurrentProject.AccessConnection
Dim Workrs1 As ADODB.Recordset
Set Workrs1 = New ADODB.Recordset


With Workrs1
Set .ActiveConnection = cn
.Source = "Select * from tblcustomerappquery where firstname =" &
Forms!test1!ssn
.LockType = adLockBatchOptimistic
.CursorType = adOpenKeyset

.Open
End With
Set Forms("test").Recordset = Workrs1
firstnamef = Workrs1("firstname")

Thanks for the help.
 
Two things...

If the field you're looking at is string then you'll need some single speech
marks in there e.g.

..Source = "Select * from tblcustomerappquery where firstname ='" &
Forms!test1!ssn &"'"

Second thing... you appear to be trying to compare a firstname field to a
form control containing a social security number.
 
Back
Top