What's the trick

S

SAL

Hello,
I've tried everything I can think of to open a form from another form and
apply a filter with no luck. I'm using Access XP and have tried the
following from my main form:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmPhotos"
stLinkCriteria = "VisitID = " & Form_frmVisit!VisitID
DoCmd.OpenForm stDocName , , , stLinkCriteria

I have also tried the following in this same routine:
Form_frmPhotos.Filter = stLinkCriteria
Form_frmPhotos.FilterOn = True

There are three records in the backend database (sql server 2005) with a
VisitID = 391 and it doesn't show any of them. The DataSource for this form
is dbo.Photo.

What do I have to do to get this form to open up with the correct records
showing?

Thanks for any help on this I've wracked my brain.
S
 
D

Douglas J. Steele

If you just open the form normally (i.e.: clicking on it or whatever), do
you see the 3 rows with VisitID 391?

Also, while the ID is obviously a number, is VisitID a numeric field, or is
it a text field? If it's a text field, you need quotes around the value:

stLinkCriteria = "VisitID = '" & Form_frmVisit!VisitID & "'"

Exagerated for clarity, that's

stLinkCriteria = "VisitID = ' " & Form_frmVisit!VisitID & " ' "
 
S

SAL

There are a total of four records in the Photo table, three with VisitID =
391 and one with a VisitID of 392.
PhotoID VisitID Photo
53 392 W:\PROJECT\011111, outfall screening\MONITORING\Photos and
Graphics\IDDE photos\06 ID393.JPG
54 391 W:\PROJECT\011111, outfall screening\MONITORING\Photos and
Graphics\IDDE photos\06 ID351.JPG
55 391 W:\PROJECT\011111, outfall screening\MONITORING\Photos and
Graphics\IDDE photos\06 ID351.JPG
59 391 W:\PROJECT\011111, outfall screening\MONITORING\Photos and
Graphics\IDDE photos\06 ID351.JPG

When I open the form by just clicking on it, it opens up with only the first
record (with VisitID = 392 in the Photo table showing. The record indicators
at the bottom of the form only displays one records also.
The VisitID field is of type int in the database.

Thanks
S
 

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