Form based on recordset limited to one record

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.
 
R

Rob Oldfield

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top