Filtering and displaying records into a new form

J

Joe Miller

I have a database that when you are viewing a patient you
cna click on "medical History" and it will display that
form, however, I need the same patient I am viewing to
com eup right away, with access to all of the other
patients still ( no filter). I can code it so that the
only patient left is the one viewed, but then I can't
scroll through the others. I need the curren tone to come
up, but with access to the others.

I was given this code for a 'non-filtering' option,
however, the third line will not be accepted, any other
ideas?

Private Sub ButtonName_Click()
On Error Goto Err_Sub

Dim rst As DAO.Recordset

stDocName = "YourFormName"
stLinkCriteria = stLinkCriteria = "[Patient Number]="
& "'" & Me![Acct
#] & "'"
DoCmd.OpenForm stDocName 'Do Not Supply Link
Criteria Here

Set rst = Forms!YourFormName.RecordsetClone
rst.FindFirst stLinkCriteria 'Link
Criteria goes here
If rst.EOF Then
MsgBox "Record not found"
Else
Me.Recordset.Bookmark = rst.Bookmark
End If

Exit_Sub:
On Error Resume Next
rst.close
Set rst = Nothing
Err_Sub:
MsgBox Err.Description
Resume Exit_Sub
End Sub

Thanks! Joe
 
E

Emilia Maxim

Joe Miller said:
I have a database that when you are viewing a patient you
cna click on "medical History" and it will display that
form, however, I need the same patient I am viewing to
com eup right away, with access to all of the other
patients still ( no filter). I can code it so that the
only patient left is the one viewed, but then I can't
scroll through the others. I need the curren tone to come
up, but with access to the others.

I was given this code for a 'non-filtering' option,
however, the third line will not be accepted, any other
ideas?
Joe,

stDocName = "YourFormName"
stLinkCriteria = stLinkCriteria = "[Patient Number]="
& "'" & Me![Acct
#] & "'"

This line is - honestly said - a real mess :) As it is, Access can
get pretty confused. When you assign a value or an expression to a
variable, you ought to have only one '=' sign in the whole code line,
and you're having two. And if the PatientNumber is numeric, you
wouldn't need the quotes either.

Try this:

'If PatientNumber is numeric
stLinkCriteria = "[Patient Number]=" & Me![Acct#]

'If PatientNumber is text, enclose it in single quotes
stLinkCriteria = "[Patient Number]='" & Me![Acct#] & "'"

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 

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